【发布时间】:2012-03-18 13:33:01
【问题描述】:
我想创建一个包含 5 个索引的数组,每个索引都有一个索引,每个索引都有另一个完整的数组。 5 索引内的每个数组都需要如下索引(10、100、1000、10000),但我不知道如何在我的 for 循环中填充这样的数组,通常与数组一起使用,没有它运行到无穷大,因为我在哪里 for(int x = 0; x
如果这有助于更好地理解,所有这些代码也是它自己类的方法的一部分。
public int ArrayArray(int arraySize, int randomNumber) {
arraySizes = arraySize;
for(int x = 0; x < array.length; x++) {
size = 0;
Random gen = new Random(randomNumber);
int[]ten;
ten = new int[arraySize];
int[] hundred;
hundred = new int[arraySize];
int[]thousand;
thousand = new int[arraySize];
int[]tenThousand;
tenThousand = new int[arraySize];
int[] array = {ten[x] = gen.nextInt(10), hundred[x] = gen.nextInt(100),
thousand[x] = gen.nextInt(1000), tenThousand[x] = gen.nextInt(10000)};
return array[];
}
这稍微改变了我的问题,我认为我在处理后得到了它。这看起来会返回我想要它做的事情吗?我将有一个驱动程序,我将使用给定的数组大小和给定数量的随机整数调用此方法。
【问题讨论】:
-
您可以编辑您的帖子并输入您遇到问题的代码吗?
-
是的。发布您的代码,我在处理您的问题时遇到了困难。
-
这个方法的返回也不起作用
-
退货是您目前唯一遇到的问题吗?
-
是的,我不确定我应该返回什么
标签: java arrays methods for-loop