标签:display print color array opened import arrays while return
1 package 彩票中奖码生成器; 2 3 import java.util.Random; 4 5 public class TestRandom { 6 public static void main(String[] args) { 7 Random random=new Random(); 8 int[] numbers=new int[6]; 9 int index=0; 10 while(index<numbers.length){ 11 int num=random.nextInt(50); 12 if(!isContains(numbers,num)) 13 numbers[index++]=num; 14 } 15 java.util.Arrays.sort(numbers); 16 for(int i:numbers){ 17 System.out.print(i+","); 18 } 19 } 20 public static boolean isContains(int[] tmp,int num){ 21 if(num==0) 22 return true; 23 for(int i=0;i<tmp.length;i++){ 24 if(tmp[i]==num) 25 return true; 26 } 27 return false; 28 } 29 }
【java】彩票中奖码生成器:java.util.Random里的方法public int nextInt(int bound)
标签:display print color array opened import arrays while return
原文地址:http://www.cnblogs.com/xiongjiawei/p/6679979.html