Here you can find the source of randomElement(int[] anArray)
public static int randomElement(int[] anArray)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { private static Random rand = new Random(); public static int randomElement(int[] anArray) { if (anArray.length == 0) { return 0; }/*from www. j a va2 s .c o m*/ return anArray[nextInt(anArray.length)]; } public static String randomElement(String[] anArray) { if (anArray.length == 0) { return ""; } return anArray[nextInt(anArray.length)]; } public static int nextInt() { return rand.nextInt(); } public static int nextInt(int n) { return rand.nextInt(n); } }