So I am trying to make a for loop that searches through an array and returns how many missing values it has found.
Here is my method:
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.");
}
The error is where the if statement is. I am assuming it is because of the null. How can I go around finding missing values?
ERROR: incomparable types: int and
answers
out of scope, array out of bounds, etc.