.values()
You can call the values() method on your enum.
values()
for (Direction dir : Direction.values()) { // do what you want}
This values() method is implicitly declared by the compiler. So it is not listed on Enum doc.
Enum
All the constants of an enum type can be obtained by calling the implicit public static T[] values() method of that type:
public static T[] values()
for (Direction d : Direction.values()) { System.out.println(d); }
You can do this as follows:
for (Direction direction : EnumSet.allOf(Direction.class)) { // do stuff}