修复代码运行报错

This commit is contained in:
peierlong 2018-09-06 18:26:39 +08:00
parent 9aebc4660f
commit bd7d42b516

View File

@ -211,14 +211,13 @@ public enum EnumSingleton {
// 反射获取实例测试
try {
Constructor<EnumSingleton> constructor = EnumSingleton.class.getDeclaredConstructor();
constructor.setAccessible(true);
EnumSingleton enumSingleton = constructor.newInstance();
System.out.println(enumSingleton.getObjName());
EnumSingleton[] enumConstants = EnumSingleton.class.getEnumConstants();
for (EnumSingleton enumConstant : enumConstants) {
System.out.println(enumConstant.getObjName());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}