+ 1
How can I choose random numbers but only from some selected numbers like 1, 2 and 3.
This question if from JAVA... Edit: And one more thing please in also want to add MIN and MAX in it...
4 Answers
+ 4
Dhruvan Rai here is a small code I made both with just a random number
and the second part is an array randomized
https://code.sololearn.com/crAqBoad9u7L/?ref=app
+ 3
Make an array of the selected numbers and let the random number generator pick any array element randomly.
+ 2
List<Integer> lista = Arrays.asList(1, 2, 3, 4, 5);
Random aleatorio = new Random();
int r = lista.get(aleatorio.nextInt(lista.size()));
System.out.println(r);
+ 1
Rai ji jay Prasuram