why cant we use orginal for loop for Set : <p>The basic difference between the set and the list is that set wont allow the duplicates 
the question is why cant we use original for loop for the set as we use for list</p>

<p>eg: length of set and list is same</p>

<pre><code>   for(int i =0 ; i&lt; list.size;i++){
    list.get(i);
    set.get(i);  // here it is throwing an error like get(index ) cant be applied for set
</code></pre>

<p>}</p>

<p>but if i use advance for loop(for each) its working </p>

<pre><code>for(Object sample : set){
 system.out.println(sample);
</code></pre>

<p>}</p>

<p>why is this happening ... is there any operational defference between for loop and for each , set and list ....</p>

<p>any help and suggestion would be  useful ... thank you in advance</p>
