This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 3064
    
  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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: comparison of List & ArrayList
 
Similar Threads
basic question about ArrayList
size of the list
Object Creation
collection
Collections.copy method for lists ? how it works