java - How to randomly pick an element from an array -


i looking solution pick number randomly integer array.

for example have array new int[]{1,2,3}, how can pick number randomly?

public static int getrandom(int[] array) {     int rnd = new random().nextint(array.length);     return array[rnd]; } 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

php - Improving script execution time -

How to provide Authorization & Authentication using Asp.net, C#? -