0

Re-asking because my other thread wasn't clear and I didn't understand the true problem.

public class Test extends Survey
{
    ArrayList<Answer> answerList;
    ArrayList<Question> questionList;

    public Test()
    {
    questionList = new ArrayList<Question>();
    answerList = new ArrayList<Answer>();
    ...
    }
 ...
}

In the eclipse debugger, it's showing answerList value as null, while questionList is not. What gives?

Edit: Is it possible my debugger is messed up? I can't get it to stop where I'm setting break points. It's stopping at old ones and ignoring new ones. I didn't set up a new configuration or anything.

6
  • Do you re-declare answerList later on? Where is it showing as null? Can you post an [SSCCE](http:/sscce.org)? Commented Oct 27, 2012 at 5:29
  • 1
    where is your breakpoint? it makes perfect sense if it's in the line of answerList = new ArrayList<Answer>(); Commented Oct 27, 2012 at 5:29
  • There's no issue with that code; you've likely later reinitialized answerList as null. Commented Oct 27, 2012 at 5:29
  • @onemach has a good point. If your breakpoint is on the initialization line, that line has note yet executed and the value will still be null. Commented Oct 27, 2012 at 5:30
  • The breakpoint is after that line is executed, and that's where it's showing as null. And no, it is not being reinitialized as null later. However, I'm having trouble with the debugger getting to stop at new break points now. Could that be related? I haven't changed configurations or anything, but it's ignoring new breakpoints. Commented Oct 27, 2012 at 5:40

2 Answers 2

3

Keep your breakpoint on the next line to

 answerList = new ArrayList<Answer>();

And then check answerList. Because If your breakpoint is on the initialization line, that line has not executed yet and the value will be null at that time.

Sign up to request clarification or add additional context in comments.

4 Comments

Is it possible my debugger is messed up? I can't get it to stop where I'm setting break points. It's stopping at old ones and ignoring new ones. I didn't set up a new configuration or anything. For what it's worth, the breakpoint is after that line.
Are you compiling in eclipse? If not, make sure your source symbols are in sync with the compiled code.
Yes, I'm doing everything in eclipse.
@iiacp Restart your eclipse and then debug it. Or Make a new class with the same code and then put your debug point after this line.
2

Where is your breakpoint? It makes perfect sense if it's in the line of answerList = new ArrayList<Answer>();. When you set a breakpoint and eclipse breaks on it, everything you see is what you are before the execution of that line.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.