0

I'm getting a strange NullPointerException, evidently thrown by the following line of code:

Iterator<Note> it = notes.iterator();

I've checked, and at the time the java.util.TreeSet notes is always non-null (with 15 elements). The TreeSet API says nothing about iterator() throwing NullPointerExceptions. What else could be going here?

2
  • Can you post the code where you populate the tree and where you're instantiating notes? Commented Mar 14, 2010 at 22:35
  • Can we see the stack trace? Are you 100% sure the NPE was thrown at this line? Commented Mar 14, 2010 at 22:43

1 Answer 1

2

If notes is not null then:

  • You are mistaken (never discount this option).
  • The implementation of notes is broken.
  • You are using the implementation incorrectly - for instance having multiple threads access it at once.
Sign up to request clarification or add additional context in comments.

1 Comment

If the NPE came from the line he says, then (1) is the only explanation that I can see. The other two options would cause the NPE elsewhere.

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.