wood burning stoves 2.0*
The moose likes JSP and the fly likes Difference between ArrayList & LinkedList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Difference between ArrayList & LinkedList" Watch "Difference between ArrayList & LinkedList" New topic
Author

Difference between ArrayList & LinkedList

RajeshDuray
Greenhorn

Joined: May 25, 2006
Posts: 11
Hai
I need Difference between ArrayList & LinkedList.
Tell me the schenario which to use when?
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
1. What is the difference between a LinkedList and an ArrayList? Why would I use a LinkedList instead of an ArrayList?

ANSWER: a) A LinkedList is similar to an ArrayList in that it is ordered by index position, but it differs in that the elements are double-linked to one another. This linkage gives you new mehtods for adding and removing from the beginning or end.

b) If your program frequently provides random access to the data of the list, the ArrayList class offers quick access to individual elements of the list. This quick access comes at a cost of slower operations for adding and removing in the middle of the list. If this latter behavior is what you desire, than the LinkedList class offers a better alternative. It provides quick sequential access, additions, and deletes, at a cost of slower random access.


Source


My blood is tested +ve for Java.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Please take the time to choose the correct forum for a question. This has nothing to do with JSP. Moved to Java in General (beginner).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Consider Paul's rocket mass heater.
 
subject: Difference between ArrayList & LinkedList