title: java while (LinkedList.iterator().hasNext()) does not work
body: <p>I have the following while loop, if I put this.boatTripsList.iterator().hasNext() in the while loop condition, it throws error. When I create iterator then put in the while loop condition, it will work then. Why is this? Thanks &amp; Regards. (the second version throws error)</p>
  
  <pre><code> public Journey(List&lt;BoatTrip&gt; trips) {
     this.boatTripsList = new LinkedList&lt;BoatTrip&gt;();
     Iterator&lt;BoatTrip&gt; iterator = trips.iterator();
     //add the given boat trips to the boattrips list
      while (iterator.hasNext()) {
           BoatTrip thistrip = iterator.next();
           this.boatTripsList.add(thistrip);
      }
  }
  
  
  
  public Journey(List&lt;BoatTrip&gt; trips) {
     this.boatTripsList = new LinkedList&lt;BoatTrip&gt;();
     //add the given boat trips to the boattrips list
      while (trips.iterator().hasNext()) {
           BoatTrip thistrip = iterator.next();
           this.boatTripsList.add(thistrip);
      }
  }
  </code></pre>