Tuesday, March 25, 2014

List vs ArrayList


List is an interface and ArrayList is an implementation of the List interface. 
The arraylist class has only a few methods in addition to the methods available in the List interface. 
There is not much difference in this. 

The only difference is, you are creating a reference of the parent interface in the first one and a reference of the class which implements the List (i.e) the ArrayList class in the second.
 If u use the first, you will be able to call the methods available in the List interface and you cannot make calls to the new methods available in the ArrayList class. Where as, u are free to use all the methods available in the ArrayList, if u use the second one.

http://www.javabeat.net/difference-between-list-and-arraylist/

No comments:

Post a Comment