随机字符串排序程序!请多多指教!
public void sort3(){
List<String> stringList=new ArrayList<String>();
String s="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random=new Random();
for(int i=0;i<10;i++){
StringBuffer str=new StringBuffer();
do{
for(int j=0;j<random.nextInt(10);j++){
int num=random.nextInt(s.length());
str.append(s.charAt(num)); }
}while(stringList.contains(str.toString()));
stringList.add(str.toString());}
System.out.println("------------排序前-----------------");
for(String string:stringList){
System.out.println("字符串为:"+string);
}
Collections.sort(stringList);
System.out.println("------------排序后-----------------");
for(String string:stringList){
System.out.println("字符串为:"+string);
}
}