how to get element random in arraylist java code example
Example 1: get random String from array list
Random r = new Random();
int randomitem = r.nextInt(myList.size());
String randomElement = myList.get(randomitem);
Example 2: get n random elements from list java
List<Foo> list = createItSomehow();
Collections.shuffle(list);
Foo foo = list.get(0);