Skip to content

Commit

Permalink
修复代码运行报错
Browse files Browse the repository at this point in the history
  • Loading branch information
peiel committed Sep 6, 2018
1 parent 9aebc46 commit bd7d42b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions notes/设计模式.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
}

Expand Down

0 comments on commit bd7d42b

Please sign in to comment.