慕斯7356729
2019-08-08 18:21
public void testStringSort(){ List<String> string = new ArrayList<>(); StringBuilder sb = new StringBuilder(); Random random = new Random(); String str = "ancdefjhigklmnopqrstuvwxyz0123456789ABCDEFGHIGKLMNOPQRSTUVWXYZ"; for(int i = 0;i<10;i++){ sb.delete(0, sb.length()); for(int j = 0;j<10;j++){ int number = random.nextInt(62); sb.append(str.charAt(number)); } if(!(string.contains(sb))){ string.add(sb.toString()); System.out.println("新添加字符串:"+sb); }else{ System.out.println("已有此字符串"); } } System.out.println("********打印前*********"); for (String strings:string) { System.out.print(strings); System.out.println(); } Collections.sort(string); System.out.println("********打印后*********"); for (String strings:string) { System.out.print(strings); System.out.println(); } }
sb.delete(0, sb.length());
请问这一行代码的作用是什么呢?
Java入门第三季
409792 学习 · 4340 问题
相似问题