I'm new to Java and had a newbie question. I am trying to randomly retrieve an enum value as below.
public enum ParkedCar {
car1(....),
car2(....);
......
}
Random rand = new Random();
int i = 1 + rand.nextInt(5);
String s = "car" + i;
ParkedCar car = ParkedCar.$s;
However, unlike in Perl where we can use $s to insert the value of s, $s is not valid in Java. What is the Java equivalent if one exists?
Thanks!