public enum WeekDay { // First,Second,Three,Four,Fix,Six,Seven; INSTANCE; public static WeekDay getIntance(){ if(INSTANCE!=null) { return INSTANCE; } return INSTANCE; } }
下面是利用反射读取
try { Class forName = Class.forName("com.lideng.parse.WeekDay"); Constructor[] constructors = forName.getConstructors(); for (int i = 0; i < constructors.length; i++) { System.out.println(constructors[i]); } } catch (ClassNotFoundException e) { e.printStackTrace(); } }