1 packagecom.hm.test;2 3 Importjava.util.Random;4 5 /**6 * Analog color ball generation7 * * * The random number of a basketball generated from 1 to 168 1 to 33 produces a random number of 6 red balls9 * @authorHMTen */ one public classDoublebar { a - public Static voidmain (string[] Args) { - int[] A =Redbar (); the -System.out.println ("the resulting color ball number is:"); - - for(inti = 0; I < a.length; i++){ +System.out.print (a[i] + ""); - } + System.out.println (bluebar ()); a } at - /*generate a random number of blue balls*/ - public Static intBluebar () { -Random random =NewRandom (); - returnRandom.nextint (16) + 1; - } in - /*generate random numbers of 6 red balls*/ to public Static int[] redbar () { + int[] A =New int[6]; -Random random =NewRandom (); the * /*Save the resulting number in the array*/ $ for(inti = 0; I < 6; i + +){Panax Notoginsenga[i] = Random.nextint (33) + 1; - } the returna; + } a the}
Using Java arrays to implement color ball select numbers