我试图搜索我的数组列表“lottoraws”是否包含我的随机数组c,具有的整数。我想打印多少数字的数组,c,这是数组列表中的数组。它告诉了Lottoraw有多少修正。在Arraylist中搜索数组的内容
//代码:
lottoraws=new ArrayList<int []>();
}
public void addLottoraws(int 5) { // for example 5
int[] a = {};
//------------------------Generate random numbers into arraylist
Random random = new Random();
for (int i = 0; i < 5; i++) {
a = new int[7];
for (int j = 0; j < 7; j++) {
int rand = (int) (random.nextInt(35));
a[j] = rand;
}
lottoraws.add(a);
}
for (int k = 0; k < lottoraws.size(); k++) {
System.out.println(Arrays.toString(lottoraws.get(k)));
}
// -------------------------Generate random numbers into array
int[] c = new int[7];
for (int j = 0; j < 7; j++) {
int rand = (int) (Math.random() * 35 + 1);
c[j] = rand;
}
System.out.println("Dragen rad: \n" + Arrays.toString(c));
//------------------------...--..-.-.-.-.-.---------Show result
什么是你的问题? – 2015-04-04 10:47:33
你只需要普通数字或数字本身的数量 – 2015-04-04 10:50:22
我只想搜索“c”中的数字,然后打印数列中的数字。所以只打印countervalue。它可能在0-7之间的值上打印,具体取决于randomgen。 – Johan 2015-04-04 10:53:32