File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes comparison of List & ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "comparison of List & ArrayList" Watch "comparison of List & ArrayList" New topic

comparison of List & ArrayList

k sabeerdeen

Joined: Mar 11, 2010
Posts: 14
hi experts,

what is the difference between the two :

List list= new ArrayList();

ArrayList list = new ArrayList();

thanks in advace!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3152

It is something called Coding to the interface.
With the first- We could assign instances of anything which implements List- ArrayList, LinkedList, Vector to the list reference
In the second case- We can assign instances of ArrayList only.

Mohamed Sanaulla | My Blog
I agree. Here's the link:
subject: comparison of List & ArrayList
It's not a secret anymore!