Java tutorial
//package com.java2s; import android.util.Log; import java.util.ArrayList; public class Main { public static ArrayList<Long> generateNumbers(String phoneNo) { Log.i("Generating Phone Numbers, from input " + phoneNo, ""); int maxLength = 10; int len = phoneNo.length(); int missing = maxLength - len; String phoneNoStart = phoneNo; String phoneNoEnd = phoneNo; for (int i = 0; i < missing; i++) { phoneNoStart = phoneNoStart + "0"; phoneNoEnd = phoneNoEnd + "9"; } long phoneStart = Long.parseLong(phoneNoStart); long phoneEnd = Long.parseLong(phoneNoEnd); ArrayList<Long> phoneNoList = new ArrayList<Long>(); for (long j = phoneStart; j <= phoneEnd; j++) { phoneNoList.add(j); } return phoneNoList; } }