.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.
Related Contents:
- Why is printing “B” dramatically slower than printing “#”?
- Is there a way to access an iteration-counter in Java’s for-each loop?
- How to efficiently remove all null elements from a ArrayList or String Array?
- Null check in an enhanced for loop
- How to make for loops in Java increase by increments other than 1
- Breaking out of a for loop in Java [closed]
- How does a for loop work, specifically for(;;)?
- How to get an enum value from a string value in Java
- Comparing Java enum members: == or equals()?
- How do I break out of nested loops in Java?
- Convert from enum ordinal to enum type
- Coding Conventions – Naming Enums
- Java: Check if enum contains a given string?
- Implementing Singleton with an Enum (in Java)
- Pick a random value from an enum?
- Is it possible to assign numeric value to an enum in Java?
- Ways to save enums in database
- Is there a way to avoid null check before the for-each loop iteration starts? [duplicate]
- Best way to define error codes/strings in Java?
- For what value of i does while (i == i + 1) {} loop forever?
- Java Enum Methods – return opposite direction enum
- Why does a 4 billion-iteration Java loop take only 2 ms?
- Java: Initialize multiple variables in for loop init?
- Iterate enum values using java generics
- Getting enum associated with int value
- Static enum vs. Non-static enum [duplicate]
- Getting String value from enum in Java
- Java enum reverse look-up best practice
- serialize and deserialize enum with Gson [duplicate]
- Why can’t I create an enum in an inner class in Java?
- Java enum and additional class files
- Enum.values() vs EnumSet.allOf( ). Which one is more preferable?
- How to define static constants in a Java enum?
- Implementing toString on Java enums
- Java: Enum vs. Int
- Enhanced FOR loops in C++
- Cyclic inheritance when implementing inner interface in enum
- Java getting the Enum name given the Enum Value
- Why can’t enums be declared locally in a method?
- What are the differences between a Java enum and a class with private constructor? [duplicate]
- What is the usage of default when the switch is for an enum?
- How to write a Java-enum-like class with multiple data fields in C++?
- How to get number of possible items of an Enum?
- Technical reasons behind formatting when incrementing by 1 in a ‘for’ loop?
- Best Loop Idiom for special casing the last element
- How to match int to enum
- Can I make an abstract enum in Java?
- Can I use enum parameter into JpaRepository nativeQuery?
- Enums and android annotation intDef
- Is there a Java enum for filesize units that’s equivalent to java.util.concurrent.TimeUnit?