开发者

Null pointer exception on .iterator() call

开发者 https://www.devze.com 2022-12-22 18:15 出处:网络
I\'m getting a strange NullPointerException, evidently thrown by the following line of code: Iterator<Note> it = notes.iterator();

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?


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消