Here you can find the source of getRandomNumber(int bit)
public static String getRandomNumber(int bit)
//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); } }