*
The moose likes Beginning Java and the fly likes LinkList Vs. Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "LinkList Vs. Vector" Watch "LinkList Vs. Vector" New topic
Author

LinkList Vs. Vector

Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
What is LinkList?
what is difference between LinkList and Vector?
Thanks,
Angela
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
If you look at the API for both these classes you will notice that LinkedList extends the
java.util.AbstractSequentialList
while the Vector class extends java.util.AbstractList
The most significant difference in terms of use is that the Vector is an array. You can add elements only at the end.
To the LinkedList you can add elements in the end, in the beginning or anywhere in the middle. That is how you keep the list in a sorted order.
Hope this helps
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Thanks a lot Shivaji,
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Ummm... you can add elements at the beginning, middle, or end of either structure. But in some cases, the performace is good - in others, it's really bad. Vectors are good for adding or removing elements near the end - the further you are from the end, the slower it is. LinkedLists are not quite as fast as Vectors at the end of the list, but they're no slower at the beginning or middle, which makes them much better than Vectors for that type of work.
Angela, most of the detailed differences are discussed at length in other forums here - specifically, "Java in General (intermediate)" and "Performance". Try using "search" (in the upper right corner of your screen) to find past discussions in those forums. At the beginner level, all Lists (Vector, ArrayList, LinkedList) are pretty much interchangeable.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LinkList Vs. Vector