I have a really strange enum bug in Java.
for(Answer ans : assessmentResult.getAnswersAsList()) { //originally stored in a table
//AnswerStatus stat = ans.getStatus();
if (ans.getStatus() == AnswerStatus.NOT_ASSESSED) {
assessed = false;
}
}
An answer is an answer to a question on a test. An assessment result is the result a student gets on a test (this includes a collection of answers).
I've debugged the above code, and ans.getStatus()
returns AnswerStatus.ASSESSED
.
Still, the if line returns true, and assessed is set to false.
But, the thing I think is most strange; When I declare the AnswerStatus
stat variable, it works, even if I don't use the stat variable in the if test. Could someone tell me what is going on?.
I've read something about enum bugs in serialization/RMI-IIOP but I don't use that here.
The enum AnswerStatus
can be ASSESSED
or NOT_ASSESSED
.
The getStatus
method in class Answer
just returns the status, nothing else.