package com.imooc.collection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class Testsort {
public int qiusuijishu(int length)
{
Random random=new Random();
int k=random.nextInt(length);
return k;
}
public String shengchengsuijizifuchuan(int changdu)
{
String choose="1234567890abcdefghijklmnopqrstABCDEFGHIGKLMNOPQRST";
StringBuffer sBuffer=new StringBuffer();
int length=choose.length();
for(int i=0;i<changdu;i++)
{
sBuffer.append(choose.charAt(qiusuijishu(length-1)));
}
return sBuffer.toString();
}
public void sort3()
{
Random two=new Random();
List<String> newlist3=new ArrayList<String>();
for(int i=0;i<10;i++)
{
int k=two.nextInt(62);
newlist3.add(shengchengsuijizifuchuan(k));
}
System.out.println("排序前字符串为");
shuchu(newlist3);
Collections.sort(newlist3);
System.out.println("排序后的字符串为");
shuchu(newlist3);
}
public void shuchu(List newlist)
{
for (Object url : newlist) {
System.out.println(url);
}
}
public static void main(String[] args)
{
Testsort one=new Testsort();
one.sort3();
}
}