package sort3;import java.util.ArrayList;import java.util.List;import java.util.Random;public class Sort { List<String> stringList=new ArrayList<>(); String str="jlksdjfflksjfj18fu347883745987"; String string;//错误好像在这里 for(int j=0;j<5;j++) { do { StringBuilder stringBuilder=new StringBuilder(); Random random;//error int i=random.nextInt(10); for(int k=0;k<i;k++) { char singleChar=str.charAt(random.nextInt(str.length())); stringBuilder.append(singleChar); } string =String.valueOf(stringBuilder);//what System.out.println("生成了随机字符串"+string); }while(stringList.contains(string)); stringList.add(string); } System.out.println("-------------排序前------------"); for(String string1:stringList) { System.out.println("字符串:"+string1); } System.out.println("-------------排序后------------"); for(String string2:stringList) { System.out.println("字符串:"+string2);}}}
添加回答
举报
0/150
提交
取消