EnumSet.of(E first, E... rest) has the following syntax.
@SafeVarargs public static <E extends Enum <E>> EnumSet <E> of(E first, E... rest)
In the following code shows how to use EnumSet.of(E first, E... rest) method.
// w w w .j av a 2s .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.