Here you can find the source of getRandNum(int charCount)
public static String getRandNum(int charCount)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { public static String getRandNum(int charCount) { String charValue = ""; for (int i = 0; i < charCount; i++) { char c = (char) (randomInt(0, 10) + '0'); charValue += String.valueOf(c); }//from w w w .ja v a 2 s .c om return charValue; } public static int randomInt(int from, int to) { Random r = new Random(); return from + r.nextInt(to - from); } }