Could any one explain,what is the difference between creating reference name using Object or using Interface.

ex1

```
ArrayList li=new ArrayList();// creating reference  using class name

```

ex2

```
List li=new ArrayList()//creating reference  using interface name

```

In real scenario why developers using ex2?

What are the advantages for using ex2?