Here you can find the source of getSerialNumber(int length)
public static String getSerialNumber(int length)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { public static String getSerialNumber(int length) { StringBuffer stringBuffer = new StringBuffer(); Random random = new Random(); for (int i = 1; i <= length; i++) { stringBuffer.append(random.nextInt(9) + 1); }//from w ww.j av a 2 s . c o m return stringBuffer.toString(); } }