java抽奖程序
package choujiang;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class choujiang {
ArrayList
public ArrayList
if(number==null){
number=new ArrayList
for(int i=1;i<1000;i++){
number.add(i);
}
}
Collections.shuffle(number);
return (number);
}
public void display(){
Random r=new Random();
int a=r.nextInt(1000);
System.out.println("一等奖是:"+number.get(a)+"号");
number.remove(a);
Collections.shuffle(number);
for(int j=1;j<=2;j++){
a=r.nextInt(1000);
System.out.println("二等奖是:"+number.get(a)+"号");
number.remove(a);
}
for(int j=1;j<=3;j++){
a=r.nextInt(1000);
System.out.println("三等奖是:"+number.get(a)+"号");
number.remove(a);
}
}
public static void main(String[]args){
choujiang g =new choujiang();
g.deal();
g.display();
}
}