手记

生成10位的随机字符串

public String testString(){
Random random = new Random();
StringBuffer SB= new StringBuffer();
String str = "qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM-=+_!@#$%^&*()[]{};':,./<>?`~";
char str1;
String str2;
for(int i = 0;i<10;i++){
str1 = str.charAt(random.nextInt(str.length()));
SB.append(str1);
}
str2 = SB.toString();
return str2;

}
0人推荐
随时随地看视频
慕课网APP