Java Programming/API/java.lang.Class

The  is defined in the  package.

There is a  object for each class in your program. The object is loaded from .class file once when the object of that type is referenced from the first time. After that it stays in memory. The object is responsible to creat all the object instances that belong to that class.

Every array also belongs to a class that is reflected as a object that is shared by all arrays with the same element type and number of dimensions. The primitive types (,, , , , , , and ), and the keyword are also represented as  objects. Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded

Since JDK 1.5 the class java.lang.Class is generic. It's an interesting example of using genericity for something other than a container/collection class.

For example, the type of String.class is Class, and the type of Serializable.class is Class. This can be used to improve the type safety of your reflection code.