我得到數組索引超出範圍異常在prog的最後一行, output[1][1]
在那裏產生這樣的異常。但在前面的循環中,同樣的事情仍然正常。數組索引超出範圍異常無故
{
int ict=66,total_slots=12,h1=15,index_count=65;
String output[][] = new String[ict][total_slots+1];
for (int x = 0; x < (ict); x++)
output[x][0] = Integer.toString(x);
for (int y = 0; y < (total_slots + 1); y++)
output[0][y] = Integer.toString(y);
for (int x = 1; x <= (index_count); x++)
for (int y = 1; y <= (total_slots); y++)
output[x][y] = "n";
for (int x=1; x <= h1; x++) {
output[x][1]="y";//exception occurs here
limit[x]++;
}
}
歡迎來到Stack Overflow。請更注意代碼的格式 - 如果沒有任何縮進,*真的很難理解。請閱讀http://tinyurl.com/stack-hints –
h1的價值是什麼? – hasnae
@DenysSéguret:希望我的確如此:) –