title: Can I store the returned object from Iterator.next() method?
body: <p>I have read that Iterator .next() method returns the object, but I get an error saying it is not a statement. I am pretty new to Java, so help would be very appreciated!</p>
  
  <p>I have tried with both Iterator, Iterator and ListIterator. I get the same error. My code is for homework and is pretty long, so I will just add what I think is most relevant here. Please ask if you need to see more!</p>
  
  <pre><code>Iterator&lt;Person&gt; itr = work.iterator();
  while (itr.hasNext()){
    Person this = itr.next();
    if (this.birthday == time){
      if (once == 0){
        System.out.println("Birthday: "+time);
        once++;
      }
      work.remove(this);
  </code></pre>
  
  <p>As you can see I am using the stored object multiple times, so I don't think I can use itr.next() several times as it will move to the next value.</p>
  
  <p>My error:</p>
  
  <blockquote>
    <p>Homework4.java:145: error: not a statement
              Person this = itr.next();</p>
  </blockquote>