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}
You can use the Random generator to generate a random index and return the element at that index:
//initialization Random generator = new Random(); int randomIndex = generator.nextInt(myArray.length); return myArray[randomIndex];