Search:

Type: Posts; User: Norm

Search: Search took 0.23 seconds.

  1. Replies
    13
    Views
    1,023

    Re: Help! Variable potentially getting Overwritten!

    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...
  2. Replies
    13
    Views
    1,023

    Re: Help! Variable potentially getting Overwritten!

    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...
  3. Replies
    13
    Views
    1,023

    Re: Help! Variable potentially getting Overwritten!

    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.
  4. Replies
    13
    Views
    1,023

    Re: Help! Variable potentially getting Overwritten!

    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.
  5. Replies
    13
    Views
    1,023

    Re: Help! Variable potentially getting Overwritten!

    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.
  6. Replies
    13
    Views
    1,023

    Re: Help! Variable potentially getting Overwritten!

    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...
  7. Replies
    13
    Views
    1,023

    Re: Help! Variable potentially getting Overwritten!

    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>

    ...
Results 1 to 7 of 7