enum FrontConstant{plain,bold,italic} public static void main(String[] args) { EnumSet<FrontConstant> es=EnumSet.of(FrontConstant.plain);//#14 Iterator it=es.iterator(); System.out.println("17"); while (it.hasNext()) System.out.println(it.next());//es初始化了一个元素plain 输出plain System.out.println("20"); System.out.println("22"); System.out.println(EnumSet.complementOf(es));//#14是plain 剩下bold和italic 输出{bold,italic} System.out.println("24"); EnumSet<FrontConstant> es2=EnumSet.noneOf(FrontConstant.class); es2.add(FrontConstant.plain);//#27 System.out.println("28"); System.out.println(EnumSet.complementOf(es2));//#27是plain 剩下bold和italic 输出{bold,italic} System.out.println("30"); ArrayList<FrontConstant> a1=new ArrayList<FrontConstant>(); a1.add(FrontConstant.plain); a1.add(FrontConstant.italic); EnumSet<FrontConstant> es3=EnumSet.copyOf(a1); System.out.println("37"); System.out.println(EnumSet.complementOf(es3)); //es3初始化后已经包含 plain和italic 剩下bold输出bold System.out.println("39"); }