+ 1

How to display all values of enum in java? Is that possible using loop?

https://code.sololearn.com/cn6E1KtojKI2/?ref=app

31st May 2020, 6:11 AM
Reyniel Mark Escamillas
Reyniel Mark Escamillas - avatar
5 Réponses
+ 2
enum values method return an array of all its values(enum.values()) u can store it in an array and iterate , or iterate enum.values() directly using range based for loop
31st May 2020, 8:33 AM
durian
durian - avatar
+ 2
Thank you, I get it I use the enum.values()[i] https://code.sololearn.com/cFZ6oXBnWBfJ/?ref=app
31st May 2020, 9:56 AM
Reyniel Mark Escamillas
Reyniel Mark Escamillas - avatar
+ 1
u can get all enum values as array(values() method),then iterate the array
31st May 2020, 7:00 AM
durian
durian - avatar
0
How it is implemented?
31st May 2020, 7:18 AM
Reyniel Mark Escamillas
Reyniel Mark Escamillas - avatar
0
import java.util.Arrays; .. RANK[] ar = RANK.values(); System.out.println(Arrays.toString(ar) );
31st May 2020, 10:11 AM
zemiak