Import java.util.ArrayList;
Import java.util.Collections;
Import Java.util.Random;
public class Choujiang {
Private arraylist<integer> list;
public void Deal () {
Adds a specified number of num integers to the list container
if (list = = null) {
List = new arraylist<integer> ();
for (int i=1;i<=100;i++) {
List.add (i);
}
}
To disrupt the order of elements in a list
Collections.shuffle (list);
}
How to draw: Indicate the award of the specified number of S
public void Draw () {
Random rd = new random ();
int index1 =rd.nextint (list.size ());
List.remove (INDEX1);
Collections.shuffle (list);
int Index2 =rd.nextint (list.size ());
List.remove (INDEX2);
Collections.shuffle (list);
int index3 =rd.nextint (list.size ());
System.out.println ("the number awarded first prize is:" +list.get (index1));
System.out.println ("The number for the second prize is:" +list.get (INDEX2));
System.out.println ("The number for the third prize is:" +list.get (INDEX3));
}
public static void Main (string[] args) {
TODO auto-generated Method Stub
Choujiang CJ = new Choujiang ();
Cj.deal ();
Cj.draw ();
}
}
Java Sixth time job