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

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -