package ujn.edu.collection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class Collection {
public void testSortString(){
List<String> stringslist = new ArrayList<String>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
Integer strsize = random.nextInt(10)+1;
String temp = "";
char c1;
for (;strsize>0;strsize--){
do {
int i1 = random.nextInt(128);
c1 = (char) i1;
}while(!('0'<=c1&&c1<='9'||'A'<=c1&&c1<='Z'||'a'<=c1&&c1<='z'));
temp += c1;
}
if(!stringslist.contains(temp))
stringslist.add(temp);
else i--;
}
System.out.println("排序前--------------");
for (String str:stringslist
) {
System.out.println(str);
}
Collections.sort(stringslist);
System.out.println("排序后--------------");
for (String str:stringslist
) {
System.out.println(str);
}
}
public static void main(String[] args) {
Collection collection = new Collection();
collection.testSortString();
}
}