Class是Reflection故事起源针对任何您想探勘的class唯有先为它产生一个Class object接下来才能经由它唤起为数十多个的Reflection APIs首先看看Class反射的核心类所有的操作都是围绕该类来生成的
Java允许我们从多种管道为一个class生成对应的Class object
Java代码
//运用ClassforName()
Class c = ClassforName(javalangString);
//运用getClass()每个object都有此方法
String str = abc;
Class c = strgetClass();
//运用getSuperclass()每个class对象都有此方法
Button b = new Button();
Class c = bgetClass();
Class c = cgetSuperclass();
//运用class 语法
Class c = Stringclass;
Class c = Integerclass;//javalangInteger
Class c = javaawtButtonclass;
Class c = intclass;//IntegerTYPE==intclass
Class c = int[]class;
//运用primitive wrapper classes(原始包装类)的TYPE语法
Class c = IntegerTYPE;//表示基本类型int的Class实例与intclass返回结果一样
Class c = ByteTYPE;
Class c = CharacterTYPE;
Class c = ShortTYPE;
Class c = BooleanTYPE;
Class c = LongTYPE;
Class c = FloatTYPE;
Class c = DoubleTYPE;
Class c = VoidTYPE;