List
is an interface , ArrayList
class is a specific implementation of that interface.
List<Object> listObject = new ArrayList<Object>();
With this you can change the List
implementation in future. List listObject
can invoke all the methods declared in the List
interface. In future , if you don't want the ArrayList
implementation of the List
, and change it with say a LinkedList
, you can do that :
List<Object> listObject = new LinkedList<Object>();
You will not have to alter the code which uses listObject
, if you had declared the listObject
as List
interface type, and not worry about it breaking the rest of the code because you might have used something specific to ArrayList
with this declaration:
ArrayList<Object> listObject = new ArrayList<Object>();
This is called Programming to an interface, not to an implementation.