Here you can find the source of random(int limit)
public static int random(int limit)
//package com.java2s; //License from project: Open Source License public class Main { public static int random(int limit) { return ((limit < 1) ? -1 : (int) ((Math.random() * 100000) % (limit)) + 1); }// ww w . j a va 2 s .co m }