Java EnumSet.of(E first, E... rest)

Syntax

EnumSet.of(E first, E... rest) has the following syntax.

@SafeVarargs public static <E extends Enum <E>> EnumSet <E> of(E first,      E... rest)

Example

In the following code shows how to use EnumSet.of(E first, E... rest) method.


/*w  ww. j  a  v a  2 s.  c o  m*/

import java.util.EnumSet;
enum Numbers {

   ONE, TWO, THREE, FOUR, FIVE
};
public class Main {

   public static void main(String[] args) {

      Numbers[] list = {Numbers.ONE, Numbers.THREE, Numbers.FOUR, Numbers.FIVE};


      EnumSet<Numbers>  set = EnumSet.of(Numbers.ONE, list);

      System.out.println(set);

   }
}

The code above generates the following result.