练习代码输出不了东西,哪里错了
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class CollectionsTest1 {
public void Testsort(){
List<String>stringList=new ArrayList<String>();
String str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqustuvwxyz0123456789";
StringBuilder C=new StringBuilder();
for(int i=0;i<10;i++){
Random random=new Random();
int A=random.nextInt(10);
if(A==0){
continue;
}else{for(int B=0;B<A;B++){
int num=random.nextInt(str.length());
C.append(str.charAt(num));
}
}
while(stringList.contains(C.toString())){
stringList.add(C.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);
}
}
}
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
CollectionsTest1 ct=new CollectionsTest1();
ct.Testsort();
}
}