Java.util.EnumSet.allOf() 方法


Java.util.EnumSet.allOf() 方法

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 an empty EnumSet
      EnumSet<Numbers> set = null;

      // print the set
      System.out.println(set);

      // create the set by getting all elements from Numbers
      set = EnumSet.allOf(Numbers.class);

      // print the updated set
      System.out.println("Updated set:" + set);
   }
}