public void testSortString(){
List<String> stringList=new ArrayList<String>();
Random random=new Random();
//产生随机字符串
for(int j=0;j<10;j++){
StringBuffer sb=new StringBuffer();
int num=random.nextInt(10)+1;
do{
for(int i=0;i<num;i++){
String str="qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM1234567890";
int n=random.nextInt(str.length());
sb.append(str.charAt(n));
//sb[j]+=str.charAt(n);
}
System.out.println("将要添加的字符串:"+sb);
}while(stringList.contains(sb.toString()));
stringList.add(sb.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);
}
}