Here you can find the source of choose(Random random, List
public static <T> T choose(Random random, List<T> list)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Random; public class Main { public static <T> T choose(Random random, List<T> list) { if (random == null) return list.get(0); return list.get(random.nextInt(list.size())); }/*from www. j ava2 s . c o m*/ public static <T> T choose(Random random, T... elements) { return elements[random.nextInt(elements.length)]; } public static <T> T choose(Random random, Collection<T> set) { return choose(random, new ArrayList<T>(set)); } }