wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes LinkedList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "LinkedList" Watch "LinkedList" New topic
Author

LinkedList

Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509
The elements in a LinkedList are doubly linked to each other? what does it mean?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

It means each element has a reference to two other elements. The first one is the element before the current element and the second is the element after the current element...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Sanjeev Nair
Greenhorn

Joined: Jan 03, 2009
Posts: 1
Each element in the linked list will have three parts
First part stores the reference to previous element
Second stores the data
and
Third stores reference to next element

Such a linked list which stores reference of both previous and next element, at each element is known as a doubly linked list.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

This is said because ArrayList is faster than LinkedList in traversal but ArrayList is very slow in insertion and deletion...
Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509
ok..thanks...i got it.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Originally posted by Ankit Garg:
This is said because ArrayList is faster than LinkedList in traversal but ArrayList is very slow in insertion and deletion...


Bit of an exaggeration to say ArrayList is very slow in insertion and deletion. Slower than a LinkedList, yes, but not very slow.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Originally posted by Campbell Ritchie:
Bit of an exaggeration to say ArrayList is very slow in insertion and deletion. Slower than a LinkedList, yes, but not very slow.


Yup. You are right. When we add or delete elements to it, then we don't even realize it.

But there is a reason why I said it. ArrayList is slower than LinkedList but HashMap is faster than LinkedHashMap in insertion and deletion. So in the beginning I used to get confused between these as one of the Linked collection is fast and one is slow. So I memorized it by thinking that ArrayList is very slow, Linked collections are fast but HashMap is ultra fast. So the statement came out of mind out of intuition ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LinkedList
 
Similar Threads
Which collection class would you use to store the objects?
Difference between ArrayList and LinkedList?
LinkedList and ArrayList
What is the difference between LinkedList and ArrayList ?
data structures