Java Programming/API/java.lang.Class

The Class<T> is defined in the java.lang package.

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


Since JDK 1.5 the class java.lang.Class<T> 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<String>, and the type of Serializable.class is Class<Serializable>. This can be used to improve the type safety of your reflection code.