title: Java - Iterable with own hasNext() and next(): how to do it right?
body: <p>I have a class that implements Iterable, but with own <code>hasNext()</code> and <code>next()</code> methods like this:</p>
  
  <pre><code>public class BLMovie implements Iterable&lt;BLMovieFrame&gt; {
  
  @Override
  public Iterator&lt;BLMovieFrame&gt; iterator() {
      iteratorVar = 0;
      return liste.iterator();
  }
  
  public boolean hasNext() {
      if (loop)
          return true;
      return iteratorVar &lt; liste.size();
  }
  
  public BLMovieFrame next() {
      iteratorVar = (iteratorVar++)%(liste.size()-1);
      return liste.get(iteratorVar);
  }
  
  public void remove() {
      throw new UnsupportedOperationException();
  }
  </code></pre>
  
  <p>I'm pretty sure that's not the best way to do it,<br>
   the other threads about Iterable did not seem to be concerned with own next methods, so does someone have an advice for me?  </p>