展开全部
class b {
private String aa = "hello";
private String bb = "world";
private String cc = "xxx!";
}
public class a {
public static void main(String[] args) throws ClassNotFoundException,
IllegalArgumentException, IllegalAccessException,
InstantiationException {
Class c = Class.forName("b");
Field[] fs = c.getDeclaredFields();
Map map = new HashMap();
for (int i = 0; i < fs.length; i++) {
Field f = fs[i];
f.setAccessible(true);
map.put(f.getName(), f.get(c.newInstance()));
}
System.out.println(map);
}
}
结果:62616964757a686964616fe78988e69d8331333335313235