- public class test extends SUPER {
- public static void main(String[] args) {
- Class obj = test.class.getSuperclass();//获取父类的字节码
- Field[] fields = obj.getFields();//获取公共字段
- for (Field field : fields) {//遍历字段
- System.out.println(field.getType() + " " + field.getName());
- }
- }
- }
复制代码 |