List<String> integerList = new ArrayList<String>();
Random random = new Random();
String s = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for(int i = 0 ; i < 10 ; i++) {
String s2 =new String();
Integer a = random.nextInt(9)+1;
do {
for(int j = 0 ; j < a ; j++) {
s2 += String.valueOf(s.charAt(random.nextInt(s.length())));
}
}while(integerList.contains(s2));
integerList.add(s2);
System.out.println("添加了:"+s2);
}
System.out.println("=======排序前=======");
for (String string : integerList) {
System.out.println(string);
}
Collections.sort(integerList);
System.out.println("-------排序后-------");
for (String string : integerList) {
System.out.println(string);
點擊查看更多內容
3人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦