title: Spring Batch ItemReader - Maintain pointer or remove item from List?
body: <p>I just started working with Spring Batch and was wondering what the best practice is for maintaining the list of items to read in ItemReader. The example I saw has something like:</p>
  
  <pre><code>private static List&lt;Resource&gt; items = new LinkedList&lt;Resource&gt;();
  private static int index = 0;
  
  private void initialize(){
      items.add(new Resource());
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public Model read(){
     if(index &lt; items.size())
        return new Model(items.get(index++));
     return null;
  } 
  </code></pre>
  
  <p>What are the benefits of this approach vs not using an index and simply shortening the list? E.g.:</p>
  
  <pre><code>public Model read(){
     if(items.size() &gt; 0)
        return new Model(items.remove(0));
     return null;
  }
  </code></pre>