Here you can find the source of random(long begin, long end)
private static long random(long begin, long end)
//package com.java2s; //License from project: Apache License public class Main { private static long random(long begin, long end) { long rd = begin + (long) (Math.random() * (end - begin)); if (rd == begin || rd == end) { return random(begin, end); }//from ww w .j a va2 s . c o m return rd; } }