what is the difference between creating reference name using class and using Interface
<p>Could any one explain,what is the difference between creating reference name using  Object or  using Interface.</p>

<p>ex1</p>

<pre><code>ArrayList li=new ArrayList();// creating reference  using class name
</code></pre>

<p>ex2</p>

<pre><code>List li=new ArrayList()//creating reference  using interface name
</code></pre>

<p>In real scenario why developers using ex2?</p>

<p>What are the advantages for using ex2?</p>
