ff14俾斯麦歼灭战攻略
0
2025 / 06 / 23
你这里的numbers是一个对象数组,所以你可以这样遍历,单个对象是不行的。遍历对象内部成员,在反射里面有方法,我刚练习完,只有将对象的成员分解到数组中才行。分享给你了:
Class c=Class.forName("AbstractClassTest.Car");//要包名+类名
Object o=c.newInstance();
Car car=(Car)o;
Field[] fields=c.getDeclaredFields();//拿到数据成员
Method[] methods=c.getMethods();//拿到函数成员
/*System.out.println(fields.length);
System.out.println(methods.length);*/
for(Field f: fields){
System.out.println("该类的内部变量有:"+f.getName());
}
for(Method m: methods){
System.out.println("该类的方法有:"+m.getName());
}