Here you can find the source of getRandNum(int num)
public static String getRandNum(int num)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { public static String getRandNum(int num) { String res = ""; if (num < 1) return res; String arr[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; for (int i = 0; i < num; i++) { Random ran = new Random(); int index = ran.nextInt(10); res = res + arr[index];//from ww w. ja va2 s . c o m } return res; } }