首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java Class 的通译

2012-09-04 
Java Class 的翻译java.langClass ClassTjava.lang.Object?? ? ? ? ? ??java.lang.ClassT?Type Parame

Java Class 的翻译
java.langClass Class<T>java.lang.Object?? ? ? ? ? ??java.lang.Class<T>?
Type Parameters:T - the type of the class modeled by this Class object. For example, the type of String.class is?Class<String>. Use Class<?> if the class being modeled is unknown.All Implemented Interfaces:?Serializable, AnnotatedElement, GenericDeclaration, Type?--------------------------------------------
public final class Class<T>extends Objectimplements 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 an annotation(注释) 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, and double), and the keyword void are also represented as Class objects.?The following example uses a Class object to print the class name of an object:?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.?

void printClassName(Object obj) {System.out.println("The class of " + obj +" is " + obj.getClass().getName());}
It is also possible to get the Class object for a named type (or for void) using a class literal. See Section 15.8.2 of The Java? Language Specification. For example:?System.out.println("The name of class Foo is: "+Foo.class.getName());

热点排行