This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Arraylist or linked list Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Arraylist or linked list" Watch "Arraylist or linked list" New topic
Author

Arraylist or linked list

krishnan jeevan
Greenhorn

Joined: Sep 06, 2011
Posts: 2
what is difference between arraylist and linked list?which is faster?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1778
Please read through http://download.oracle.com/javase/6/docs/api/java/util/ArrayList.html and http://download.oracle.com/javase/6/docs/api/java/util/LinkedList.html.

Faster? - it depends on the operation you intend to do with them (... and of course the way the code is written!)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9955
    
    6

which is faster?

You will quickly learn that the answer to almost EVERY question related to programming and "which is better/faster" is always "It depends". In a nutshell, it is going to be faster to FIND a specific element (I.e the 27th) in an array.

Searching for the element where you don't know the location will be roughly the same for both - unless they are sorted, then an array can be faster.

Inserting a new element in the middle will be faster in a linked list...although I'm not sure if that is still true if you have to find the spot to insert it.

In short, there is no simple answer to the question as stated.


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arraylist or linked list
 
Similar Threads
print random letters(LinkedList)
records/linked list/deletion
advantage Doublylink list over linklist
WA #1.....word association
What is the difference between ArrayList and Vector