title: ListIterator.next() returns null
body: <p>my question is really, really simple, but everything I find online tells me I am doing it the right way - but I obviously misunderstood something.</p>
  
  <p>I have a simple, simple Java ListIterator, which in a while-hasNext()-loop returns a null for next(). Here's the code with my comments on the debug state:</p>
  
  <pre><code>[...]
  ListIterator&lt;Role&gt; rolesIterator = currentUser.getRoles().listIterator();
  // rolesIterator is now: java.util.ArrayList$ListItr
  while( rolesIterator.hasNext() ) {
          Role roleObject = rolesIterator.next(); // extra step for debugging reasons
          String role = roleObject.getName(); // NullPointerException - roleObject is null
  [...]
  </code></pre>
  
  <p>In my thoughts, the loop should not be entered, if there is no next() object - that's why I check using hasNext(). What did I understand wrong, and what is the correct way?</p>