Java Random Number randomNumber(int length)

Here you can find the source of randomNumber(int length)

Description

random Number

License

Open Source License

Declaration

public static String randomNumber(int length) 

Method Source Code


//package com.java2s;
import java.util.*;

public class Main {
    static final char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
    static final Random rand = new Random();

    public static String randomNumber(int length) {
        StringBuffer sb = new StringBuffer();
        for (int loop = 0; loop < length; ++loop) {
            sb.append(digits[rand.nextInt(digits.length)]);
        }//www . ja  v  a  2s  .c  om
        return sb.toString();
    }
}

Related

  1. getrannumber()
  2. getRndNumByLen(int lengthOfNumber)
  3. getSerialNumber(int length)
  4. getTenByteNumber()
  5. randomHexNumber(final int length)
  6. randomNumber(int min, int max, Random r)
  7. randperm(int number)