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