public void testSort4(){
List<StringBuilder> StringIntegerList = new ArrayList<StringBuilder>();
//保存所需要的字符
String a = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random random = new Random();
int k = random.nextInt(10);
StringBuilder str = new StringBuilder();
for(int j = 0;j < 10;j++){
for(int i = 0;i < k;i++){
int number = random.nextInt(a.length());
str.append(a.charAt(number));
}
StringIntegerList.add(str);
System.out.println("将要添加字符串:" + "'" + str +"'");
//清空str里的字符串
str.delete(0, k);
}
}
但是collections的sort的方法好像对StringBuilder不适用。