Here you can find the source of getRandomTarget(List
public static <T> T getRandomTarget(List<T> targets)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.concurrent.ThreadLocalRandom; public class Main { public static <T> T getRandomTarget(List<T> targets) { int randomIndex = ThreadLocalRandom.current().nextInt(targets.size()); return targets.get(randomIndex); }//w w w .j a v a 2s. c o m }