所以我試圖做一個for循環來搜索一個數組並返回找到的缺失值。使用for循環查找數組中的缺失值
這裏是我的方法:
public void questionsMissed() {
int missedQuestions = 0;
for (int i = 0; i < 20; i++) {
if (answers[i] == null){
missedQuestions++;
}
}
System.out.println("You have missed " + missedQuestions + " questions.");
}
的錯誤就是if語句。我認爲這是因爲空。我怎樣才能找到缺失的值?
錯誤:無法比擬的類型:int和
告訴我們完整的代碼和問題 – 2014-11-05 18:49:33
你得到了什麼錯誤? – Eran 2014-11-05 18:49:48
...和錯誤,請 – Mureinik 2014-11-05 18:49:51