Here you can find the source of getRandomNumber(int startNumber, int endNumber)
public static int getRandomNumber(int startNumber, int endNumber)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static int getRandomNumber(int startNumber, int endNumber) { Random randomGenerator = new Random(); long range = (long) startNumber - (long) endNumber + 1; long fraction = (long) (range * randomGenerator.nextDouble()); int randomNumber = (int) (fraction + startNumber); return (Math.abs(randomNumber) == 0) ? getRandomNumber(startNumber, endNumber) : Math.abs(randomNumber); }//from www. j a va 2 s .c o m }