Here you can find the source of random(long range)
public static long random(long range)
//package com.java2s; public class Main { /** Returns a random value in the range [1 - range] */ public static long random(long range) { return (long) ((Math.random() * 100000) % range) + 1; }//from w w w.j av a 2s. c o m }