-
Type Parameters:
-
T- the type of the class modeled by thisClassobject. For example, the type ofString.classisClass<String>. UseClass<?>if the class being modeled is unknown.
- Serializable, AnnotatedElement, GenericDeclaration, Type
类的类型设计是通过这类的object对象,例如,string类的类型是class<String>.
使用这个class<?>被设计的是不知道的
All Implemented Interfaces:
public final class Class<T>
extends
Object
implements
Serializable,
GenericDeclaration,
Type,
AnnotatedElement
Instances of the class Class represent(表现,代表) classes and interfaces in a running Java application. An enum is a kind of class and anannotation(批注) is a kind of interface. 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(规模). The primitive Java types (boolean, byte, char, short, int, long, float, anddouble), and the keyword(关键字) void are also represented as Class objects.
类的实例表现类和接口在java的应用程序中,枚举是类的一种,和..是一种接口。
每个数组被存放一个类,这个类是作为一个类的object对象反射,object对象反射类通过数组中这相同元素类型和
Java类型boolean, byte, char, short, int, long, float, anddouble和关键字 void 是作为一个类对象
Class has no public constructor(构造). Instead(反而) 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.
类没有共有的构造函数,反而类被自动加载通过Java虚拟机调用defineClass 方法
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());
}
-
Since:
- JDK1.0 See Also:
-
ClassLoader.defineClass(byte[], int, int), Serialized Form
本文深入解析了Java中的Class类,包括其如何代表运行中的Java应用中的类和接口,以及它是如何为枚举、注解、数组、基本类型等提供反射支持。文章还介绍了Class类的实现细节和使用示例。

被折叠的 条评论
为什么被折叠?



