This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
If I say System.out.println(Object.class), I get as output the toString method of the Class class. Is there a hidden field class of type Class in Object? Because in JDK documentation I do not see any field in Object.
Hello Carlo Object.class is a class literal. This is from JLS
15.8.2 Class Literals A class literal is an expression consisting of the name of a class, interface, array, or primitive type followed by a `.' and the token class. The type of a class literal is Class. It evaluates to the Class object for the named type (or for void) as defined by the defining class loader of the class of the current instance.
Also the wrappers clases and java.lang.Void class have a TYPE field containing a Class object for the corresponding type: Integer.TYPE <==> Integer.class ... Void.TYPE <==> Void.class
I am sorry I did a mistake in my previous answer. The fields Integer.TYPE ... Void.TYPE holds references to int.class ... void.class objects. Integer.class represents the Class object for java.lang.Integer class. Also Void.class is a class literal for java.lang.Void