### Question:
ClassUtil { public final static String[] getPublicField(String className, boolean extendsField) { Class classz = loadClass(className); Set<String> set = new HashSet<>(); Field[] fields = classz.getDeclaredFields(); if (fields != null) { for (Field f : fields) { String modifier = Modifier.toString(f.getModifiers()); if (modifier.startsWith("public")) { set.add(f.getName()); } } } if (extendsField) { Field[] fieldz = classz.getFields(); if (fieldz != null) { for (Field f : fieldz) { set.add(f.getName()); } } } return set.toArray(new String[set.size()]); }  static ClassLoader getContextClassLoader(); final static String[] getField(String className, boolean extendsField); final static String[] getPublicField(String className, boolean extendsField); final static String[] getProtectedField(String className); final static String[] getPrivateField(String className); final static String[] getPublicMethod(String className, boolean extendsMethod); final static String[] getProtectedMethod(String className, boolean extendsMethod); final static String[] getPrivateMethod(String className); final static String[] getMethod(String className, boolean extendsMethod); final static void setter(Object obj, String att, Object value, Class<?> type); final static List<String> getClassNameByFile(String filePath, boolean childPackage); final static List<String> getClassNameByJar(String jarPath); final static Class loadClass(String className); final static List<String> getResourceNameByJar(String jarPath); final static List<String> getResourceNameByJar(String jarPath, String suffix); static List<Class> getLoaderClass(ClassLoader classLoader); final static String getSuperClass(String className); final static String[] getSuperClassChian(String className); final static String[] getInterfaces(String className, boolean extendsInterfaces); static File getFile(String resourceLocation); static File getFile(URL resourceUrl); static File getFile(URL resourceUrl, String description); static URI toURI(URL url); static URI toURI(String location); static ClassLoader overridenClassLoader; }### Answer:
@Test public void testPublicField() { System.out.println("=============获取类中的全部public属性包括继承的=========="); String[] fields = ClassUtil.getPublicField("com.opslab.temp.model.BusinessLog", true); for (String f : fields) { System.out.println(f); } System.out.println("=============获取类中的自定义public属性包括继承的=========="); String[] fieldz = ClassUtil.getPublicField("com.opslab.temp.model.BusinessLog", false); for (String f : fieldz) { System.out.println(f); } }