EnumSet在这种情况下可能会有所帮助。鉴于以下情况,
public enum Resolution { RES_32(32), RES_64(64), RES_128(128), RES_256(256); public static Set<Resolution> deluxe = EnumSet.allOf(Resolution.class); public static Set<Resolution> typical = EnumSet.range(RES_64, RES_128); public static Set<Resolution> ecomomy = EnumSet.of(RES_32); private final int asInt; private Resolution(int asInt) { this.asInt = asInt; }};
如下所示,可以使用适当命名的集合。
for (Resolution r : Resolution.deluxe) { System.out.println(r.asInt);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)