Random number class instances in Java Common class library

Source: Internet
Author: User
Tags set set

http://www.verejava.com/?id=169931132381103

/** Knowledge Points: Random number class practical application: Enemy aircraft randomly from the top of the screen appears */import java.util.*;p ublic class testrandomcard{public static void main    (string[] args)                      {string[] cards={"A", "a", "a", "a", "2", "2", "2", "2", "3", "3", "3", "3",                      "4", "4", "4", "4", "5", "5", "5", "5", "6", "6", "6", "6",                      "7", "7", "7", "7", "8", "8", "8", "8", "9", "9", "9", "9", "Ten", "Ten", "Ten", "Ten", "J", "J", "J", "J", "Q", "Q", "Q", "Q", "K"        , "K", "K", "K", "Xiao Wang", "King"};        System.out.println ("Original card:");        for (int i=0;i<cards.length;i++) {System.out.print (cards[i]+ ",");        }//Randomly scrambling Set set=new HashSet ();        Random rn=new random ();            while (true) {Set.add (Rn.nextint (54)); if (set.siZe () ==54) {break;        }} System.out.println ("\n54 Random index Number:");        Object[] Iter=set.toarray ();        for (int i=0;i<iter.length;i++) {System.out.print (iter[i]+ ",");        } List zhanshan=new ArrayList ();        List lisi=new ArrayList ();            List wangwu=new ArrayList (); }}

http://www.verejava.com/?id=169931132381103

Random number class instances in Java Common class library

Related Article

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.