Anybody tell me the difference ?
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi
can anybody tell me the difference between
LinkedList , ArrayList and Vector
Thanks !!
can anybody tell me the difference between
LinkedList , ArrayList and Vector
Thanks !!
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Well in simple terms the main difference between
ArrayList,Vector with LinkedList is linkedlist is sequetinal access mechanisam. Hence linkedlist is preferred where you wish to get the list of values in a sequential manner and Arraylist/vector is perferred where you need random lookup of values.
now the difference between vector and arraylist is vector is syncronized where as arraylist is not.
Hope this helps
ArrayList,Vector with LinkedList is linkedlist is sequetinal access mechanisam. Hence linkedlist is preferred where you wish to get the list of values in a sequential manner and Arraylist/vector is perferred where you need random lookup of values.
now the difference between vector and arraylist is vector is syncronized where as arraylist is not.
Hope this helps

SCJP 1.4 (86%)<br />SCMAD Beta (77%)<br />SCEA (part I:89%,partII:93%)<br />MCAD (cleared 70-315 & 70-320 [Score 980])
Preszio let
Greenhorn
Posts: 4
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You can also look at some Newsletter articles:
Collections 1
Collections 2
The first artciles covers lists while the second one covers sets.
I hope that helps,
Corey
Collections 1
Collections 2
The first artciles covers lists while the second one covers sets.
I hope that helps,
Corey
posted 22 years ago
That is not really correct. Both, ArrayList and LinkedList are Lists and thus store the values in an ordered fashion. Search for a random element will require a serial lookup through the whole list.
Advantages and disadvantage of ArrayList and LinkedList arise from the fact that ArrayList is based on an array while LinkedList is beased on a linked list. Therefore, adding and removing elements from the middle of the list will be faster in a LinkedList than in an ArrayList (because of the shift of element positions). For this reason, stack style operation are faster in a LinkedList.
Memorywise, ArrayList should be more efficient than a LinkedList because LinkedList stores two references (front and back) per element. ArrayList will also be more efficient if you want to add tons on elements in one shot and then just reading the List (not adding/removing values).
HTH,
Paul.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Lawrence Chettiar:
Hence linkedlist is preferred where you wish to get the list of values in a sequential manner and Arraylist/vector is perferred where you need random lookup of values.
That is not really correct. Both, ArrayList and LinkedList are Lists and thus store the values in an ordered fashion. Search for a random element will require a serial lookup through the whole list.
Advantages and disadvantage of ArrayList and LinkedList arise from the fact that ArrayList is based on an array while LinkedList is beased on a linked list. Therefore, adding and removing elements from the middle of the list will be faster in a LinkedList than in an ArrayList (because of the shift of element positions). For this reason, stack style operation are faster in a LinkedList.
Memorywise, ArrayList should be more efficient than a LinkedList because LinkedList stores two references (front and back) per element. ArrayList will also be more efficient if you want to add tons on elements in one shot and then just reading the List (not adding/removing values).
HTH,
Paul.
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
LinkedList is much poorer than ArrayList for access by means of an index as it requires a sequential scan from the front or back of the list, ie not random access at all. ArrayList has fast random access as it is backed by an array, whereas LinkedList is doubly-linked list.
Both are pretty good at iterating through a list, both retrieve in insertion order.
What hasn't been mentioned yet is that a LinkedList can simulate a stack, queue or double-ended queue (deque). So, if you want to implement something like a FIFO queue, then linkedLIst has the methods to add and remove the first elements in the list.
Both are pretty good at iterating through a list, both retrieve in insertion order.
What hasn't been mentioned yet is that a LinkedList can simulate a stack, queue or double-ended queue (deque). So, if you want to implement something like a FIFO queue, then linkedLIst has the methods to add and remove the first elements in the list.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Corey McGlone
Ranch Hand
Posts: 3271
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
If you look into the two articles I indicated earlier, you'll find actual benchmarks for performance of the various collections. Perhaps perusing those articles would be worth-while. 

posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi
Do you think Performance is included in SCJP ?
Do you think Performance is included in SCJP ?
SCJP 2 1.4
Robbie kyodo
Ranch Hand
Posts: 97
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Let me summarize all your tots
LinkedList
-Sequential Access
-Non-synchornized
-Use index
-FIFO, stack, dequeu
Vector
-Random Access
-Synchronized
ArrayList
-Random Access
-Non-synchronized
-resize itself
Anymore things to add ?
LinkedList
-Sequential Access
-Non-synchornized
-Use index
-FIFO, stack, dequeu
Vector
-Random Access
-Synchronized
ArrayList
-Random Access
-Non-synchronized
-resize itself
Anymore things to add ?
SCJP 2 1.4
Robbie kyodo
Ranch Hand
Posts: 97
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Just read the two articles, do you have the Map interface version.
Both articles are great !!
Both articles are great !!
SCJP 2 1.4
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The Map article is in the August 2002 newsletter at : Collections3
Roger Chung-Wee
Ranch Hand
Posts: 1683
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Robbie,
ArrayList is the modern version of Vector. It is faster, largely because it is not synchronized.
Use ArrayList for new code. If you have to use Vector, normally because you are modifying existing code or dealing with some method which requires a vector, try and get accustomed to the new way of working. You can do this because Vector has been re-engineered to bring it into line with the Collections Framework way of working. For instance, use List's add method rather than addElement to add an element to the end of the vector. Or use iterator to return an Iterator rather than elements to return an Enumeration.
ArrayList is the modern version of Vector. It is faster, largely because it is not synchronized.
Use ArrayList for new code. If you have to use Vector, normally because you are modifying existing code or dealing with some method which requires a vector, try and get accustomed to the new way of working. You can do this because Vector has been re-engineered to bring it into line with the Collections Framework way of working. For instance, use List's add method rather than addElement to add an element to the end of the vector. Or use iterator to return an Iterator rather than elements to return an Enumeration.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You should never use Vector. If you need a synchronized List then use the synchronization method of the Collections class:
The fourth and final article
The fourth and final article
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
| this is supposed to be a surprise, but it smells like a tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |






