title: What are the major differences between a Collection, an ArrayList, and a List in Java?
body: <p>An ArrayList, a List and a Collection in Java behaves almost in the same way and they have many methods in common. If such is a case then, what are the major differences among them? The following simple code snippet demonstrates it.</p>
  
  <pre><code>package collections;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  
  final public class Main
  {
      public static void main(String[] args) 
      {
          Collection&lt;String&gt; collection=new ArrayList&lt;String&gt;();
          List&lt;String&gt;list=new ArrayList&lt;String&gt;();
          ArrayList&lt;String&gt;arrayList=new ArrayList&lt;String&gt;();        
  
          collection.add("A");
          collection.add("B");
  
          list.add("A");
          list.add("B");
  
          arrayList.add("A");
          arrayList.add("B");
  
          Iterator&lt;String&gt;collectionIterator=collection.iterator();
          Iterator&lt;String&gt;listIterator=list.iterator();
          Iterator&lt;String&gt;arrayListIterator=arrayList.iterator();
  
          while(collectionIterator.hasNext())
          {
              System.out.println(collectionIterator.next());
          }
  
          while(listIterator.hasNext())
          {
              System.out.println(listIterator.next());
          }
  
          while(arrayListIterator.hasNext())
          {
              System.out.println(arrayListIterator.next());
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p>When and where to use an ArrayList, a Collection and a List? In which specific situations, the differences among them may be remarkable?</p>