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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

post - imageshack API cURL -

dataset - MPAndroidchart returning no chart Data available -