Here you can find the source of randomIntWithDigits(int digits)
public static int randomIntWithDigits(int digits)
//package com.java2s; //License from project: Apache License public class Main { public static int randomIntWithDigits(int digits) { int max = (int) Math.pow(10, digits) + 1; return randomIntWithMinMax(0, max); }//from w w w . j a va2 s .c om public static int randomIntWithMinMax(int min, int max) { return (int) (min + (Math.random() * (max - min + 1))); } }