![]() |
VOOZH | about |
The EnumSet.range() method is a part of the java.util package. This method is used to create an EnumSet that contains all enum constants between the specified start and end points, and it should be inclusive. It easily creates a subset of enum constants within a specified range.
EnumSet<E> range(E start_point, E end_point)
Parameters: The method accepts two parameters of the object type of enum:
Return Value: The method returns the enum set created by the elements mentioned within the specified range.
Exceptions: The method throws two types of exceptions:
Example 1: In this example, we will create an EnumSet using the range() method with the GFG enum.
Example 2: In this example, we will use the range() method with a different enum called CARS.
Important Points: