Here you can find the source of getNumber()
public static String getNumber()
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { private static final Random RANDOM = new Random(); private static final char[] NUMBER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; private static final int NUMBER_LENGTH = NUMBER.length; public static String getNumber() { return getNumber(2); }//from ww w . j a va 2 s . com public static String getNumber(int n) { StringBuilder res = new StringBuilder(); for (int i = 0; i < n; i++) res.append(NUMBER[RANDOM.nextInt(NUMBER_LENGTH)]); return res.toString(); } }