public class AppTest { private NodeClass nodeClass; public static String hehe = "hehe"; public String xixi = "xixi"; public void test() { Field[] fields = AppTest.class.getDeclaredFields(); try { for (Field field : fields) { field.setAccessible(true); if(field.getType().toString().endsWith("java.lang.String") && Modifier.isStatic(field.getModifiers())) System.out.println(field.getName() + " , " + field.get(AppTest.class)); } } catch (Exception e) { e.printStackTrace(); } } }
本文转自 小眼儿 博客园博客,原文链接:http://www.cnblogs.com/hujunzheng/p/6808590.html,如需转载请自行联系原作者