public void testSort3() {
List<String> stringList = new ArrayList<String>();
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
for (int j = 0; j < 10; j++) {
int x;
StringBuffer st = new StringBuffer();
do{
x = random.nextInt(11);
for (int i = 0; i < x; i++) {
st.append(str.charAt(random.nextInt(62)));
}
}while(stringList.contains(st)||x==0);
stringList.add(st.toString());
}
System.out.println("---------------排序前---------------");
for (String string : stringList) {
System.out.println(string);
}
System.out.println("---------------排序后---------------");
Collections.sort(stringList);
for (String string : stringList) {
System.out.println(string);
}
}
打开App,阅读手记