Here you can find the source of genRandomNumber(int minNumber, int maxNumber, int digits)
public static int genRandomNumber(int minNumber, int maxNumber, int digits)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { private static Random randGen = new Random(); public static int genRandomNumber(int minNumber, int maxNumber, int digits) { boolean chkExit = true; int isValueOk = randGen.nextInt(digits + 1); while (chkExit) { if (isValueOk < minNumber || isValueOk > maxNumber) { isValueOk = randGen.nextInt(digits + 1); } else { chkExit = false;/*from w w w . jav a 2s . com*/ } } return isValueOk; } }