随机生成指定位数的字符串

public String createRandom(int n){

StringBuffer str = new StringBuffer();

for(int i=0;i<n;i++){

if(i==0 && n>1){

str.append(new Random().nextInt(9)+1);

}else{

str.append(new Random().nextInt(10));

}

}

return str.toString();

}

原文地址:https://www.cnblogs.com/mangwusuozhi/p/13750822.html