Paul Clapham wrote:Well, wall of text aside, when I see a NullPointerException my first instinct is to decide that is a symptom of a problem in my code. So I go and look at the stacktrace which it is at the top of. That's what I would recommend you do, too. Then you can see which line of your code is incorrectly trying to dereference a null value, and fix it accordingly.
Paul Clapham wrote:It's because you keep getting a new iterator for "elements", so you keep starting at the beginning every time around the loop.
Soren Frank wrote:I've only been programming for a few months, so I'm learning by failing at the moment.