日期:2014-05-18 浏览次数:20711 次
private static GroupForm abc = new GroupForm();
private static GroupForm bbb = new GroupForm();
private static Tttttt ddd = new Tttttt();
public static void main(String[] args) throws IOException {
//MainTest是定义的地方
Field[] fields = MainTest.class.getDeclaredFields();
if(fields != null && fields.length > 0) {
for(Field f : fields) {
Type t = f.getGenericType();
if(t instanceof Class<?>) {
Class<?> cls = (Class<?>)t;
//这里GroupForm就是你想要找的类
if(GroupForm.class.isAssignableFrom(cls)){
//输出变量名
System.out.println(f.getName());
}
}
}
}
}