Here you can find the source of listChooseOne(List
public static <T> T listChooseOne(List<T> list)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.Random; public class Main { private static Random R = new Random(); public static <T> T listChooseOne(List<T> list) { if (list.size() == 1) { return list.get(0); }/*w w w. ja v a2 s . c o m*/ if (list.size() > 1) { return list.get(R.nextInt(list.size())); } return null; } }