Java Random Number getRandNum(int charCount)

Here you can find the source of getRandNum(int charCount)

Description

get Rand Num

License

Open Source License

Declaration

public static String getRandNum(int charCount) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {
    public static String getRandNum(int charCount) {
        String charValue = "";
        for (int i = 0; i < charCount; i++) {
            char c = (char) (randomInt(0, 10) + '0');
            charValue += String.valueOf(c);
        }//from  w  w  w  .ja  v  a  2  s  .c om
        return charValue;
    }

    public static int randomInt(int from, int to) {
        Random r = new Random();
        return from + r.nextInt(to - from);
    }
}

Related

  1. getNumbers()
  2. getNumbersAndAlphabet()
  3. getNumString(int length)
  4. getPhoneNumber()
  5. getPositiveNumber(int maximum)
  6. getRandNum(int num)
  7. getRandNum(int num)
  8. getRandNumber(int maxNumber)
  9. getRandomDouble(double max, String decimalFormat)