Java Random Number getRandomNumber(int length)

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

Description

get Random Number

License

Open Source License

Parameter

Parameter Description
length a parameter

Declaration

public static String getRandomNumber(int length) 

Method Source Code

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

import java.util.Random;

public class Main {
    /**//from   w w w.j  ava 2  s  . c om
     * @param length
     * @return
     */
    public static String getRandomNumber(int length) {
        String result = "";
        Random r = new Random();
        while (0 < length) {
            length -= 1;
            result += r.nextInt(9);
        }
        return result;
    }
}

Related

  1. getRandomNumber(int bit)
  2. getRandomNumber(int bound)
  3. getRandomNumber(int digit)
  4. getRandomNumber(int len)
  5. getRandomNumber(int len)
  6. getRandomNumber(int length)
  7. getRandomNumber(int length)
  8. getRandomNumber(int max, boolean include0)
  9. getRandomNumber(int max, int count)