Java Utililty Methods Random Number

List of utility methods to do Random Number

Description

The list of methods to do Random Number are organized into topic(s).

Method

intgenRandomNumber()
gen Random Number
if (randomNumber == null) {
    randomNumber = new Random();
    randomNumber.setSeed(System.currentTimeMillis());
int i = randomNumber.nextInt();
if (i < 0) {
    i *= -1;
return i;
intgenRandomNumber(int begin, int end)
gen Random Number
int step = Math.abs(end - begin);
int random = new Random(System.nanoTime()).nextInt(step);
return Math.min(begin, end) + random;
StringgenRandomNumber(int digitNumber)
gen Random Number
StringBuilder num = new StringBuilder();
Random random = new Random();
for (int i = 0; i < digitNumber; i++) {
    num.append(random.nextInt(10));
return num.toString();
intgenRandomNumber(int minNumber, int maxNumber, int digits)
gen Random Number
boolean chkExit = true;
int isValueOk = randGen.nextInt(digits + 1);
while (chkExit) {
    if (isValueOk < minNumber || isValueOk > maxNumber) {
        isValueOk = randGen.nextInt(digits + 1);
    } else {
        chkExit = false;
return isValueOk;
StringgenRandomNumberString(int numberCount)
gen Random Number String
return genRandomString(1, NONEZERO_NUMBER_CHARS) + genRandomString(numberCount - 1, NUMBER_CHARS);
ListgenRandomNumList(int num, int count)
gen Random Num List
if (num < count) {
    return Collections.EMPTY_LIST;
List<Integer> result = new ArrayList<Integer>();
Map<Integer, String> containMap = new HashMap<Integer, String>();
Integer temp = null;
Random random = new Random();
for (int i = 0; i < count;) {
...
booleangetChance(Number number)
get Chance
return getChance(number.intValue());
StringgetDocumentNumber()
get Document Number
Random random = new Random();
int select = random.nextInt(99) * 1234;
int select2 = random.nextInt(alphas.length);
return alphas[select2] + "0" + select;
StringgetFlightNumber()
get Flight Number
Random random = new Random();
Integer select = random.nextInt(999);
return select.toString();
intgetNextRandomNumber()
get Next Random Number
return rand.nextInt();