我想創建一個由5個索引組成的數組,索引與每個數組中的另一個整數組成索引。 5索引中的每個數組都需要如下所示的索引(10,100,1000,10000),但我不知道如何在我的for循環內填充這樣的數組,這通常與數組一起使用,而沒有它運行到無窮大,因爲我有 for(int x = 0; x < array.length; x ++), 我不能在這裏使用x變量; int [x < - (syntax error)] array = {ten = new int [arraySize],hundred = new int [arraySize],thousand = new int [arraySize],tenthousand = new int [arraySize], without it告訴我有一個語法錯誤。我不知道該怎麼辦。我需要知道如何用其他數組填充數組索引
所有這些代碼都是自己類的方法的一部分,如果這有助於更好地理解。
公衆詮釋ArrayArray(INT ARRAYSIZE,詮釋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[];
}
這改變了我的問題有點我認爲香港專業教育學院在其上工作過之後,得到了它。這看起來像它會返回我想要它做什麼?即時通訊將有一個驅動程序,我將調用此方法給定的數組大小和給定數量的隨機整數。
你能編輯你的文章,並把你有問題的代碼? – moesef 2012-02-29 02:34:26
是的。發佈你的代碼,我很難處理你的問題。 – Marl 2012-02-29 02:47:29
這種方法的回報並不能順利工作 – Tigh 2012-02-29 02:51:37