package com.imooc.collection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class CollectionPractice {
public void Generate(){
String a="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
List<String> listString=new ArrayList<String>();
Integer num=a.length();
for(int i=0;i<10;i++){
Random random=new Random();
String fl="";
Integer k=random.nextInt(9)+1;
for(int m=0;m!=k;m++){
Integer n=random.nextInt(a.length());
fl+=a.charAt(n);
}
listString.add(fl);
}
System.out.println("--------排序前--------");
for (String string : listString) {
System.out.println(string);
}
System.out.println("--------排序后--------");
Collections.sort(listString);
for (String string : listString) {
System.out.println(string);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
CollectionPractice result=new CollectionPractice();
result.Generate();
}
}
點擊查看更多內容
1人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦