Here you can find the source of getNumber(int length)
public static String getNumber(int length)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static final char[] NUMBERS = "0123456789".toCharArray(); private static Random r = new Random(); public static String getNumber(int length) { StringBuilder sb = new StringBuilder(length); while (length-- > 0) { sb.append(randomChar(NUMBERS)); }// w w w . j a v a 2 s . co m return sb.toString(); } private static char randomChar(char[] letters) { int index = r.nextInt(letters.length); return letters[index]; } }