EnumSet.range(E from, E to) has the following syntax.
public static <E extends Enum <E>> EnumSet <E> range(E from, E to)
In the following code shows how to use EnumSet.range(E from, E to) method.
// w w w . j ava 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) { // create a set EnumSet<Numbers> set; // add one element set = EnumSet.range(Numbers.TWO, Numbers.FIVE); System.out.println(set); } }
The code above generates the following result.