import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class StringRom {
static String string="0123456789QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
//创建一个字符串,且每次返回一个新字符串
public void stringRandom(int k){
Random randonm=new Random();
List<String> list=new ArrayList<>();
for(int i=0;i<k;i++){
StringBuilder sb=new StringBuilder();
int lengTh=randonm.nextInt(10);
for(int j=0;j<=lengTh;j++){
int numb=randonm.nextInt(62);
sb.append(string.charAt(numb));
}
list.add(sb.toString());
}
System.out.println("~~~~~~~~排序前~~~~~~~~");
for (String str : list) {
System.out.println(str);
}
Collections.sort(list);
// return (String[]) list.toArray(new String[list.size()]);
System.out.println("~~~~~~~~排序前~~~~~~~~");
for (String str : list) {
System.out.println(str);
}
}
// public String [] stringRandomSort(String [] string){
// Collections.sort(string);
//
// }
public static void main(String[] args) {
StringRom sr=new StringRom();
sr.stringRandom(10);
}
}