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
Post a Comment