public void testSort(){
List<String> stringList = new ArrayList<String>();
char[] allchar = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z','0','1',
'2','3','4','5','6','7','8','9'};
Random random = new Random();
for(int i = 0;i<10;i++){
String k="";
int x = random.nextInt(10)+1;
for(int j=0;j<x;j++){
int z = random.nextInt(35);
int logn = (int) (Math.random()*10);
String aChar;
if(logn<5){
aChar = (allchar[z] + "").toUpperCase();
}
else{
aChar = allchar[z] + "";
}
k = k + aChar;
}
if(!stringList.contains(k)){
stringList.add(k);
}else{
i--;
}
}
System.out.println("----------排序前----------");
for(String st:stringList){
System.out.println(st);
}
Collections.sort(stringList);
System.out.println("----------排序后----------");
for(String st:stringList){
System.out.println(st);
}
}
點擊查看更多內(nèi)容
3人點贊
評論
評論
共同學(xué)習(xí),寫下你的評論
評論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦