反射。。。public class RefTest {
public static void main(String[] args) throws Exception {
new C2().fun();
}
}class Parent {
public static String st;
public void fun() throws Exception {
Class clazz = this.getClass();
Field st = clazz.getField("st");//获得名字叫st的属性
S