difference with ArrayList and List
<p>Hi Here i am trying to sublist the items from list and print them 5 for each iteration.
here in the following code it is printing same items every time</p>

<pre><code>for(int i=0;i&lt;4;i++)
    {
    List&lt;Card&gt; l=a.subList(a.size()-5, a.size());
    System.out.println(l);

 }
</code></pre>

<p>But here it is printing different items as if it is removing 5 from the list each time</p>

<pre><code> for(int i=0;i&lt;4;i++){
     int deckSize = a.size();
     List&lt;Card&gt; handView = a.subList(deckSize-5, deckSize);
     ArrayList&lt;Card&gt; hand = new ArrayList&lt;Card&gt;(handView);
     handView.clear();
     System.out.println(hand);
 }
</code></pre>

<p>what is the difference between the above two code snippets</p>
