Class A{
public String name="小名";
}
class test{
public static void main(){
A a = new A();
String value = a.getClass().getField("name");
sop(value); //打印name字段上的值
Field[] field = a.getClass().getFields();
for(Field fields:field){
fields.set(a,"小小");
}
}
} |