You forgot to print out the value of totalquestions. Its value controls what solutions element answer is compared against.
If answer can have a null value then it is an object and you should use...
Type: Posts; User: Norm
You forgot to print out the value of totalquestions. Its value controls what solutions element answer is compared against.
If answer can have a null value then it is an object and you should use...
Can you post what was printed out and the code that did the printing?
The printout should show the values of: answer, totalquestions and the full contents of solutions.
Did you also consider the...
That would mean that they were not executed. Move them outside of any if statements so that they are sure to execute. Like before the first if
and after the last else.
Integer is a class. But sometimes the compiler will automatically extract its contents and retrieve the int value it holds using a hidden process called unboxing.
What data type is answer? If it's an object, you need to use the equals() method not == to compare it.
== is for primitives like int.
Why isn't 0 a valid value? The value of score is only changed if one of the if statements is true.
If they are all false, the value won't be changed. Which if statement(s) are true?
Try debugging...
Can you post the program's output that shows what you are talking about?
I don't see where you set the value of score to 0.
Please edit your post and wrap your code with
<YOUR CODE HERE>
...