Java EnumSet.of(E e1, E e2)
Syntax
EnumSet.of(E e1, E e2) has the following syntax.
public static <E extends Enum <E>> EnumSet <E> of(E e1, E e2)
Example
In the following code shows how to use EnumSet.of(E e1, E e2) method.
//www . j a va 2s . c om
import java.util.EnumSet;
enum Numbers {
ONE, TWO, THREE, FOUR, FIVE
};
public class Main {
public static void main(String[] args) {
// create a set
EnumSet<Numbers> set;
// add elements
set = EnumSet.of(Numbers.FIVE,Numbers.FOUR);
System.out.println(set);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »