package com.ItHeima.WeekAct;
import java.util.ArrayList;
/**
* 生成0-99的100个随机数,要求不重复
* @author 支胜勇
*
*/
public class Test2 {
public static void getRandom(){
ArrayList<String> randomArr=new ArrayList<String>();
while(randomArr.size()<100){
int intRandom=(int)(Math.random()*100);
if(randomArr.contains(intRandom+";")){
continue;
}else{
randomArr.add(intRandom+";");
System.out.print(intRandom+";");
}
}
}
public static void main(String args[]){
getRandom();
}
} |
|