DRAFT
Observed
One cannot invoke toString() on a String
One can invoke toString() on a String
The toString()
method is declared in class java.lang.Object
, and thus inherited by java.lang.String
(a subclass of java.lang.Object
). As such, it’s perfectly legal to invoke toString()
on a String
object. The result will be the object itself, so the invocation is really unnecessary:
String s = ...;
assert s.toString() == s;