public void testSort3(){
List<String> strList = new ArrayList<String>();
String basicStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
for(int i =0;i < 10;i++){
StringBuffer sbf = new StringBuffer();
int length = random.nextInt(10) + 1;
for(int j = 0;j < length;j++){
int charID = random.nextInt(basicStr.length());
sbf.append(basicStr.charAt(charID));
}
if(!strList.contains(sbf.toString())){
System.out.println("添加字符串:" + sbf.toString());
strList.add(sbf.toString());
}
}
System.out.println("------排序后------");
Collections.sort(strList);
for(String str:strList){
System.out.println("元素为:" + str);
}
}