0
公共類I5Exc1a {OutofBoundException發送陣列時的方法
public static int[] reverse(int[] array)
{
int[] local = array;
int i = local.length;
int j = 0;
int[] arrayR = new int[i];
for (;i>-1; i--)
{
arrayR[j] = array[i];
j++;
}
return arrayR;
}
}
它應該接收陣列和扭轉它。但是當我測試它時,它會給我帶來不便。我試着通過製作一個額外的數組來修復它。我認爲問題在於數組的長度沒有正確傳遞給i。有誰知道我可以如何解決這個問題?
非常感謝! –