Java Sixth time job

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.