具體對象.getClass();
類名.class;
封裝類名.TYPE;
Class.forName("類名");
Class Field Constructor Method
Class
getFields()
getConstructors()
getMethods()
Field
field.setAccessible(true);
field.set(obj, "男");
(field.get(對象)獲得field的引用)
Constructor
getModifiers() getName()
getParameterTypes()
Modifier.toString(getModifiers())
newInstance(
"Rollen"
,
20
);
(反射方式使用方法)
Method
getModifiers() getReturnType() getName()
getParameterTypes()
Modifier.toString(getModifiers())
method.invoke(demo.newInstance(),"Rollen",20);(反射方式使用方法)
Annotaion
( getAnnotation(Class) field.getAnnotations() );