power_settings_new

how do I iterate through enum values in Java

by
asked
0 votes
49 views
I have a scenario where I have to utilize hashmap values. Here key is Enum and value is of type String. Enum values keeps changing. I need to write loop so that I can iterate through each enum value and get appropriate value for the same.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by (171 points)
selected by
0 votes
 
Best answer

This is what you should be doing.

 

for (ENumClass eNumClass : ENumClass.values()){
     //your code here.
}
add
...