Here you can find the source of chooseRandomElement(List
static public <Type> Type chooseRandomElement(List<Type> list, Random random)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.Random; public class Main { static public <Type> Type chooseRandomElement(List<Type> list, Random random) { final int index = random.nextInt(list.size()); return list.get(index); }// w w w. j ava 2 s . c om }