Class.toString() doesn't return what you'd expect:
assertEquals("java.lang.Integer", Integer.class.toString());`</pre>
Instead, it prefixes the fully-qualified classname with "class " for classes, "interface " for interfaces and probably "enum " and "annotation " elsewhere. You need to call `getName` or `getSimpleName()` to get what you usually want.
<pre class="prettyprint">` assertEquals("java.lang.Integer", Integer.class**.getName()**);
assertEquals("Integer", Integer.class**.getSimpleName()**);
What can I learn from this? The toString()
value is important to the usability of an API. With toString
, it's often better to be terse rather than complete.