_是谁_0
2017-12-12 16:02:03浏览 1935
List<String> integerList = new ArrayList<String>();
Random random = new Random();
String s = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for(int i = 0 ; i < 10 ; i++) {
String s2 =new String();
Integer a = random.nextInt(9)+1;
do {
for(int j = 0 ; j < a ; j++) {
s2 += String.valueOf(s.charAt(random.nextInt(s.length())));
}
}while(integerList.contains(s2));
integerList.add(s2);
System.out.println("添加了:"+s2);
}
System.out.println("=======排序前=======");
for (String string : integerList) {
System.out.println(string);
}
Collections.sort(integerList);
System.out.println("-------排序后-------");
for (String string : integerList) {
System.out.println(string);