Java Random Number getRandomNumber(int bit)

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

Description

get Random Number

License

Apache License

Declaration

public static String getRandomNumber(int bit) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {

    public static String getRandomNumber(int bit) {
        Random r = new Random();
        int randNum = r.nextInt(new Double(Math.pow(10, bit)).intValue());
        while (randNum < new Double(Math.pow(10, bit - 1)).intValue()) {
            randNum = r.nextInt(new Double(Math.pow(10, bit)).intValue());
        }// www . j a v a  2s  .c  om
        return String.valueOf(randNum);
    }
}

Related

  1. getRandomNumber()
  2. getRandomNumber()
  3. getRandomNumber()
  4. getRandomNumber(final int from, final int to)
  5. getRandomNumber(final int maxInt, final int minInt)
  6. getRandomNumber(int bound)
  7. getRandomNumber(int digit)
  8. getRandomNumber(int len)
  9. getRandomNumber(int len)