Possible Duplicate:
When to use LinkedList<> over ArrayList<>?
I saw the API for the ArrayList and LinkedList and it seems to be same. Apart from their performance difference is there any difference in terms of adding, deleting and iterating the List.
List arrList = new ArrayList();
List linList = new LinkedList();
The List arrList or linList reference is actually implementing the corresponding class. What does this actually mean?
I am not 100% sure what you mean when you ask “What does this actually mean?”, but here is a guess.
Consider code like this:
Interface a; and Implementation b; both point at the same object, but only the reference to “b” has access to the “bar” method.
So, in your example, any methods that are in the List interface are accessible to both arrList and linList, but any methods that they provide in addition to the List interface wont be callable without a cast. You can (and should in most cases) treat ArrayList and LinkedList as a List.
For the specifics of inserting/adding/deleting from the different lists, you generally should not care. Both behave the same way from the point of view of the end result (eg. the same sequence of method calls with the same data will result in the same result, just the internal layout will be different).