當我嘗試使用此方法時,我在標題中看到消息,但找不到原因。任何人都可以幫助我?線程「main」中的異常java.lang.ArrayIndexOutOfBoundsException:10
謝謝!
void companyInfo() {
int tel = 0;
System.out.print("Name of company: ");
String tmpCompany = sc.next();
for (int i = 0; i < tel; i++){
if (tmpCompany.equals(null)){
}
}
for (int i = 0; i < 10; i++) {
int count = 0;
for (int j = 0; j < field.length; j++){
for (int k = 0; k < field[k].length; k++){
if (tmpCompany != (null) && field[i][j] != 0 && tmpCompany.equals(felt[i][j])){
count++;
}
}
}
if (tmpCompany != null && count > 0) {
System.out.print("The company " + tmpCompany + " owns " + count + " field(s).");
}
}
}
你可以張貼堆棧跟蹤?數組在哪裏聲明?給我們看一看。 –
「tel」變量和第一個for循環的重點是什麼?循環從不執行其主體。 – ReyCharles
這個網站沒有每秒鐘得到50個這樣的帖子的原因是因爲你可以通過程序(使用IDE)輕鬆查看問題的確切位置。 – keyser