Here you can find the source of getRandomIntegerElement(List
public static Integer getRandomIntegerElement(List<Integer> list)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.concurrent.ThreadLocalRandom; public class Main { public static Integer getRandomIntegerElement(List<Integer> list) { Integer selectedElement = null; if (list != null && !list.isEmpty()) { int listSize = list.size(); int randomIndex = ThreadLocalRandom.current().nextInt(0, listSize); selectedElement = list.get(randomIndex); }// www . j a va 2 s .com return selectedElement; } }