java - Generating a random number from the array -
suppose there array :
int arr[] = {0,1,2}
is there way can generate random number out of 0,1,2
(i.e array) ?
try this
import java.util.random; random random = new random(); system.out.println(arr[random.nextint(arr.length)]);
Comments
Post a Comment