交作业了 ,三个循环套用
public void testChallenge() {
List <String> newst=new ArrayList<String>();
String substring="0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
Random random=new Random();
for(int m=0;m<10;m++) {
StringBuilder sb=new StringBuilder();
do{
int ss=random.nextInt(10);
for(int i=0;i<ss;i++ ) {
int sbint=random.nextInt(62);
sb.append(substring.charAt(sbint));
}
}while(newst.contains(sb));//保证字符串不重复
newst.add(sb.toString());
}
System.out.println("---------------排序前");
for(String st1:newst) {
System.out.println("排序前的字符串为:"+st1);
}
System.out.println("----------排序后");
Collections.sort(newst );
for(String st1:newst) {
System.out.println("排序后的字符串为:"+st1);
}
}