Here you can find the source of random(ArrayList
public static String random(ArrayList<String> randomValue)
//package com.java2s; import java.util.ArrayList; import java.util.Random; public class Main { public static String random(ArrayList<String> randomValue) { Random rd = new Random(); int randomInt = rd.nextInt(randomValue.size()); return randomValue.get(randomInt); }//w w w . j a v a 2 s .c om }