.values()
You can call the values()
method on your enum.
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.
More Related Contents:
- How to compare variables in a loop, java
- Basic Looping in Java
- Nested for loop in java. Am I allowed to declare a variable in the outer and increment it in the inner?
- Why is printing “B” dramatically slower than printing “#”?
- How does a for loop work, specifically for(;;)?
- Is there a way to access an iteration-counter in Java’s for-each loop?
- Creating a triangle with for loops
- How to efficiently remove all null elements from a ArrayList or String Array?
- Is there any way to do n-level nested loops in Java?
- Post increment operator not incrementing in for loop [duplicate]
- Null check in an enhanced for loop
- Breaking out of a for loop in Java [closed]
- Using for loop inside of a JSP
- Java: For-Each loop and references [duplicate]
- Java while loop query [closed]
- Looping for a random number of times java
- Creating a program to file criminal cases and then view them, with new case being allowed to add
- Java number sign and asterisk [closed]
- Can I add and remove elements of enumeration at runtime in Java
- Why can’t enum’s constructor access static fields?
- Get enum by its inner field
- Why is default required for a switch on an enum?
- Should I strictly avoid using enums on Android?
- Java String validation using enum values and annotation
- What does the colon (:) operator do?
- Getting all names in an enum as a String[]
- How can I reference my Java Enum without specifying its type
- How to get the enum type by its attribute?
- How can I run multiple commands in just one cmd windows in Java?
- Why Java does not allow overriding equals(Object) in an Enum?