aspose file tools*
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
Author

comparison of List & ArrayList

k sabeerdeen
Greenhorn

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: 3071
    
  33

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
 
Consider Paul's rocket mass heater.
 
subject: comparison of List & ArrayList