Java tutorial
//package com.java2s; import java.util.*; public class Main { private static Random random = new Random(); public static <T> T choice(List<T> list) { int stuff = random.nextInt(list.size()); for (T t : list) { if (stuff == 0) return t; else stuff -= 1; } return list.iterator().next(); } }