帮忙看看什么问题,老是报调试,还有排序后面的不显示
如题suo shi
如题suo shi
2017-07-17
public void testsort3() { String a="0123456789qwertyuiopasdfghjklzxcvbnmQWERTYIOPASDFGHJKLzxcvbnm"; Random rd=new Random(); List<String>stringList=new ArrayList<String>(); for(int i=0;i<10;i++) { StringBuilder sb=new StringBuilder(); for(int j=0;j<1+rd.nextInt(10);j++) { char cr=a.charAt((int)(rd.nextInt(62))); sb=sb.append(String.valueOf(cr)); } System.out.println("获得字符串:"+sb); stringList.add(sb.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); } }
举报