Created by Wang, Jerry on Aug 02, 2016
注意这里的softReference
public class FloatTest { public static String A = "JerryTest"; FloatTest tool = new FloatTest(); System.out.println(tool.A); Object classObject = FloatTest.class; 用下面的代码从class对象里打印出静态field的value: FloatTest tool = new FloatTest(); System.out.println(tool.A); // approach1: print static field via one class instance Object classObject = FloatTest.class; Class<FloatTest> convert = (Class<FloatTest>)classObject; Field[] fields = convert.getFields(); Field staticField = fields[0]; try { System.out.println("static field value: " + staticField.get(tool)); // approach2: via class } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); }