Here you can find the source of getNumbers()
public static String getNumbers()
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private final static int length = 6; public static String getNumbers() { Random random = new Random(); String result = random.nextInt(1000000) + ""; if (result.length() != length) { return getNumbers(); }//from w ww . ja v a2s . c o m return result; } }