Java Random Number genRandomNumber(int minNumber, int maxNumber, int digits)

Here you can find the source of genRandomNumber(int minNumber, int maxNumber, int digits)

Description

gen Random Number

License

Open Source License

Declaration

public static int genRandomNumber(int minNumber, int maxNumber, int digits) 

Method Source Code


//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;
    }
}

Related

  1. generateSaltNumber()
  2. genRandomNum(int pwd_len)
  3. genRandomNumber()
  4. genRandomNumber(int begin, int end)
  5. genRandomNumber(int digitNumber)
  6. genRandomNumberString(int numberCount)
  7. genRandomNumList(int num, int count)
  8. getChance(Number number)
  9. getDocumentNumber()