/** *产生9位不同的随机数 */ private String getRandomString(){ StringBuffer sb = new StringBuffer(); for(int i=0;i<9;i++){ sb.append((int)(Math.random()*10)); } return sb.toString(); }
相信很多人写随机数的方法有很多,但是我感觉这样所产生的随机数重复的概率最低,因为我的每一位数字都是随机出来的每个数字产生的概率是十分之一九个数字就是十的九次方,这样的概率相信已经非常的低了,