I am looking for solution to pick number randomly from an integer array.
For example I have an array new int[]{1,2,3}, how can I pick a number randomly?
new int[]{1,2,3}
Use the Random class:
int getRandomNumber(int[] arr) { return arr[(new Random()).nextInt(arr.length)]; }