public void testSort2() {
List<String> stringlist=new ArrayList<String >();
String a="dsadwqfsbcvigntlerimcjzfoweqjoeqwjoifiowqeog2128";
Random random=new Random();
for(int i=0;i<10;i++) {
String st=new String();
do {
for(int j=0;j<random.nextInt(10)+1;j++) {
int number=random.nextInt(a.length());
st=st+a.charAt(number);
}
}while(stringlist.contains(st));
stringlist.add(st);
}
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);
}
}
打开App,阅读手记