[Solved] How do yo randomly assign a value to a variable? [closed]


You should use

r.nextInt(3);

to get a number from the range 0-2. So,

switch(r.nextInt(3)) {
  case 0: myVar = "a"; break;
  case 1: myVar = "b"; break;
  case 2: myVar = "c"; break;
}

0

solved How do yo randomly assign a value to a variable? [closed]