//产生10个0-100之间不重复的随机数
List list = new ArrayList();
Random random=new Random();
while(list.size()<11){
Integer ii = new Integer(random.nextInt(100));
if(!list.contains(ii)){
list.add(ii);
}
System.out.println("-----" + list.toString());
}
//产生10个1-100之间不重复的随机数
List list=new ArrayList();
Random random=new Random();
while(list.size()<11){
Integer ii=new Integer(random.nextInt(99)+1);
if(!list.contains(ii)){
list.add(ii);
}
System.out.println("-----" + list.toString());
}
阅读(963) | 评论(0) | 转发(0) |