import java.util.*;
public class RandomDemop
{
static Random rd = new Random();//获取随机数的工具
static List nList = new ArrayList();//保存随机数
//获取随机数
public static void getRandomNum()
{
for(int i=1;i<6;i++)
{
nList.add(new Integer(rd.nextInt(5)));
}
}
//打印随机数
private static void printElements(List list)
{
for(int i=0;i<list.size();i++)
{
System.out.println(list.get(i));
}
}
public static void main(String [] arg)
{
getRandomNum();
Collections.sort(nList);
printElements(nList);
}
}
标签:java,Random,算法,static,随机数,new,播放,public From: https://blog.51cto.com/u_16229443/7135728