Answers for "how to get a random enum in java"

1

java choose random enum

return yourEnum.values()[new Random().nextInt(yourEnum.values().length)];
Posted by: Guest on May-12-2021
0

return random from enum

//Return a random int number between min [inclusive] and max [inclusive] 
//Make sure maxNumber does not exceed number of enum values
(EnumType)Random.Range(minNumber, maxNumer);
Posted by: Guest on June-21-2020
-1

get random number from enum in java

return Letter.values()[new Random().nextInt(Letter.values().length)];
Posted by: Guest on May-03-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language