The values() method within the enum type provides an array containing all enum constants. It proves handy when you need to iterate through the constants of an enum.
values()
enum Level { LOW, MEDIUM, HIGH}
public class Main { public static void main(String[] args) { for (Level myVar : Level.values()) { System.out.println(myVar); } } }
args
myVar
out