public void Stringtest2(){ List<String> string=new ArrayList<String>(); Random random=new Random(); //28 //String[]s={"q","w","e","r","t","y","u","i","o","p","[","a","s","d","f","g","h","j","k","l",";","z","x","c","v","b","n","n","m"}; String s="mnbvcxz431fghjkl&*%uytrewq"; int k; String s2=null; for(int i=0;i<10;i++){ do{ k=random.nextInt(26); s2=s.substring(k); }while (s2.length()>10); string.add(i,s2); } System.out.println("-------排序前-------"); for (String string2 : string) { System.out.println(string2); } System.out.println("-------排序后-------"); Collections.sort(string); for (String string2 : string) { System.out.println(string2); } }自己测试了,感觉还是有点规律可循,有谁能解释下吗
添加回答
举报
0/150
提交
取消