| Author |
ArrayList vs LinkedList !!
|
Gunjan Rathi
Greenhorn
Joined: Jul 19, 2006
Posts: 4
|
|
What are the differences between an ArrayList and a LinkedList ? Where do we use ArrayList and where LinkedList ?
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
ArrayList is implemented with an array to store the elements of the list. LinkedList is implemented as a doubly-linked list. Which one you should use depends on how you use the list. An ArrayList is faster when you need to lookup an element at a known index in the list, but slower when you insert elements in the list. A LinkedList is slower when looking up an element at a known index in the list, but faster when you insert elements in the list.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
Adding on top of what Jesper said, both of them are collections and used to deal with a heterogeneous elements in a sequence. As they follow different implementation strategies, they have different characteristics. I think Jesper have given a good explanation on that.
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
Amir Alagic
Ranch Hand
Joined: Mar 21, 2006
Posts: 65
|
|
|
http://narencoolgeek.blogspot.com/2006/09/arraylist-vs-linkedlist.html
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
This link is cool (also the links present inside the article).
|
 |
raghu nagabandi
Ranch Hand
Joined: Aug 14, 2007
Posts: 35
|
|
ArryList: we will use ArrayList in following cases if the requirement contains more retrival operation then we have to use ArrayList LinkedList: If the requirement contains more insertions and deletions then we will use LinkedList
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by raghu nagabandi: ArryList: we will use ArrayList in following cases if the requirement contains more retrival operation then we have to use ArrayList
Only for random access. If we always iterate through all elements of a list in order, a LinkedList should be just fine (although still a little bit slower).
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: ArrayList vs LinkedList !!
|
|
|