-2
我需要一个包含可变数目数组的数组ListList。带有可变数目数组的ArrayList
ArrayList <int[]> aa = new ArrayList<int[]>();
int b = 1;
int array [] = new int [5];
while (b == 1){
for (int i=0; i < array.length; i++){
array [i] = in.nextInt();
}
aa.add(array);
System.out.println("If you want to insert another array, press 1");
b = in.nextInt();
}
逻辑验证码不起作用,因为数组被覆盖每次和结束时的输出始终是相同的......我怎么能解决我的问题? .. :)
把循环中的数组的声明,你会很好去。 –
你为什么要硬编码数组长度? – efekctive
@efekctive。只要价值得到正确使用,为什么它很重要? –