posted 19 years ago
We normally think of an instance as an object formed by using the class as a template. So, different instances of the same class can have different state, but all refer to the same code.
However, in the Java runtime each class, interface, array, primitive and the keyword void will have its code also available in the form of an object which is an instance of java.lang.Class. Whenever we compile any Java file, the compiler will embed a coderanch, static, final field named class, of the type java.lang.Class, in the emitted byte code. This field can be accessible like this:
java.lang.Class class = Myclass.class;
SCJP 1.4, SCWCD 1.3, SCBCD 1.3