Class Class

Class java.lang.Class

Class Members | This Package | All Packages
java.lang.Object
   |
   +----java.lang.Class

public final class Class
extends Object
implements Serializable

Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. Finally, the either primitive Java types (boolean, byte, char, short, int, long, float, and double) and the keyword void are also represented as Class objects.

There is no public constructor for the class Class. Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.

The following example uses a Class object to print the Class name of an object:

void printClassName(Object obj) { System.out.println("The class of " + obj + " is " + obj.getClass().getName()); }

See Also:
defineClass