所以情况就是这样。是否可以循环使用不同参数的方法?
我在做一个锻炼; Tibial,我不得不用我所有的静态数字每个随机数从外部文件lotto.dat
我必须做出一个方法doCompare()
返回true或false比较。我的代码后,我的问题就会出现:
public static void drawNumbers()throws Exception{
Random rnd = new Random();
int rndN1 = rnd.nextInt(19)+1;
int rndN2 = rnd.nextInt(19)+1;
int rndN3 = rnd.nextInt(19)+1;
int rndN4 = rnd.nextInt(19)+1;
int rndN5 = rnd.nextInt(19)+1;
int rndN6 = rnd.nextInt(19)+1;
System.out.println();
System.out.println("Winner numbers: " + rndN1 + " " + rndN2 + " " + rndN3 + " " + rndN4 + " " + rndN5 + " " + rndN6);
String match = doCompare(rndN1);
if(match.equals("true")){
System.out.println("Match on the number: " + rndN1);
}
}
那么是否有可能以某种方式循环的“doCompare”与参数“doCompare(rndN1)”,然后rndN2,rndN3等要不然我应该怎么做才能使这项工作?
是使用一个循环... – brso05 2014-10-29 13:28:26
但我怎么做,第二次循环经历改变参数为rndN2而不是1? – user3703289 2014-10-29 13:29:22
了解馆藏,这太宽泛了,不成问题。 http://docs.oracle.com/javase/tutorial/collections/ – 2014-10-29 13:29:57