how to set item in arraylist random code example
Example 1: random object of array java
public static int getRandom(int[] array) {
int rnd = new Random().nextInt(array.length);
return array[rnd];
}
Example 2: get random String from array list
Random r = new Random();
int randomitem = r.nextInt(myList.size());
String randomElement = myList.get(randomitem);