-5
public static void main(String args[])
{
Calculation C=new Calculation();
int i;
for(i=5;i>=0;i--)
{
C.m[i]=Integer.valueOf(args[i]);
//assignment of command line arguments with the array//
}
C.display();
}
這個封裝類這給出的誤差「異常在線程‘主要’java.lang.ArrayIndexOutOfBoundsException:5」的命令行參數的輸入作爲10 20 30 40 50 60 請幫我什麼錯與for循環
什麼樣的類是''Calculation''?從錯誤消息結束,Calculation類的數組「m」的大小小於5.不能訪問索引5處的元素,因爲索引從0開始,第5個元素將在索引4處。 – rbialon
沒有足夠的信息告訴 – edtheprogrammerguy
循環假定兩個數組('args []'和'Cm []')至少有6個元素。看起來至少有一個沒有。 – David