public void testsort3(){
char[] string= {'0','1','2','3','4','5','6',
'7','8','9','a','b','c','d',
'e','f','g','h','i','j','k',
'l','m','n','o','p','q','r',
's','t','u','v','w','x','y',
'z','A','B','C','D','E','F',
'G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z'};
List<String> stringList = new ArrayList();
//可变字符串
StringBuilder sb ;
//随机字符的下标
int random ;
//循环添加字符的次数
int cishu;
//随机字符串
String s1;
do{
sb = new StringBuilder();
cishu = (int)(Math.random()*10);
//for(int i =0;i<=(int)(Math.random()*10);i++){
for(int i =0;i<=cishu;i++){
random =(int) ((Math.random()*62));
sb.append(string[random]);
}
s1 = sb.toString();
if(!stringList.contains(s1)){
stringList.add(s1);
System.out.println("添加随机字符串:"+s1+"---长度为:"+s1.length());
} }while(stringList.size()<10);
//排序前
System.out.println(stringList.toString());
Collections.sort(stringList);
//排序后
System.out.println(stringList.toString()); }