Java.util.EnumSet.noneOf() 方法


Java.util.EnumSet.noneOf() 方法

package com.codingdict;

import java.util.*;

public class EnumSetDemo {

   // create an enum
   public enum Numbers {
      ONE, TWO, THREE, FOUR, FIVE
   };

   public static void main(String[] args) {

      // create a set that contains all Numbers class
      EnumSet<Numbers> set1 = EnumSet.allOf(Numbers.class);

      // print set1
      System.out.println("Set1:" + set1);

      // create a second set which is empty
      EnumSet<Numbers> set2 = EnumSet.noneOf(Numbers.class);

      // print the new set
      System.out.println("Set2:" + set2);
   }
}