I was playing around with Classname.class and Classname.class.toString() and found something unusual.
.class seems to equate to .class when run on the same Class. Although .class.toString() does not equate to the .class.toString() on the same class. Why would this be.
Please see my code below
public class HelloWorld{
public static void main(String []args){
if(String.class.toString() == String.class.toString())
System.out.println("toString(): Yes they are the same");
else
System.out.println("toString(): They are not the same ?");
System.out.println("=============================");
if(String.class == String.class)
System.out.println(".class: Yes they are the same");
else
System.out.println(".class: They are not the same");
}
}
Output:
sh-4.3# javac HelloWorld.java
sh-4.3# java -Xmx128M -Xms16M HelloWorld
toString(): They are not the same ?
=============================
.class: Yes they are the same