import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class RandomList {
public String RandomListTest() {
char ascii;
String str = "";
for (int i = 0; i <= new Random().nextInt(10); i++) {
ascii = (char) new Random().nextInt(128);
while ((str.indexOf(ascii) != -1) || !(("" + ascii).matches("[0-9[a-zA-Z]]"))) {
ascii = (char) new Random().nextInt(128);
}
str += "" + ascii;
}
return str;
}
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String str = new RandomList().RandomListTest();
while (list.indexOf(str) != -1) {
str = new RandomList().RandomListTest();
}
list.add(str);
}
System.out.println("----------------升序前----------------");
for (String string : list) {
System.out.println(string);
}
Collections.sort(list);
System.out.println("----------------升序后----------------");
for (String string : list) {
System.out.println(string);
}
}
}