title: why upcasting for List objects? Android / Java syntax
body: <p>I have been reading code from many Android projects recently to gain more understanding.  one of the things I see is the difference in two ways that ArrayList are instantiated.</p>
  
  <p>Note these two examples shown here. why do some use example 1, and why would you do that over example 2,  what are the major differences between them?</p>
  
  <p>I understand the concept of upcasting and downcasting in Java and don't see any advantage in this particular situation. if you are going to create an arrayList why not store it in an ArrayList variable from the beginning?</p>
  
  <p>I have always used the example 2 way of creating a new ArrayList. I don't understand what is the advantage to use what is shown in example 1</p>
  
  <p>It looks like more programmers use the example 1 way</p>
  
  <p>Example 1, use of upcasting into parent variable</p>
  
  <pre><code>  List&lt;String&gt; list = new ArrayList&lt;String&gt;();
  </code></pre>
  
  <p>Example 2</p>
  
  <pre><code>  ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  </code></pre>