Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Linkedlists vs vectors

 
Ugochukwu Onwordi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,i'm currently studyn d collections framework,bt i'm having trouble identifying when 2 use a linked list instead of a vector.is there much of a difference between them?are there any general guidelines as 2 which one is best 4 a given scenario?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use real words (e.g., "to" and "for" rather than "2" and "4").
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the topic Choosing an implementation from the Collections chapter of Eckel's Thinking in Java. (And note that it says, "Hashtable, Vector, and Stack ... are legacy classes, so that old code doesn't break. ...it�s best if you don't use those for new code." In general, use an ArrayList in place of a Vector.)

In comparing ArrayList to LinkedList, you will see (for example) that an ArrayList allows for fast random access, while a LinkedList allows for fast insertions and deletions from the middle.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, I like Eckell, but All those bold words make me bug eyed. Here's a simple crib sheet for the most common (couldn't resist) choices.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
Wow, I like Eckell, but All those bold words make me bug eyed...

I agree.

For what it's worth, his convention is...
...identifiers (method, variable, and class names) are set in bold. Most keywords are also set in bold, except for those keywords that are used so much that the bolding can become tedious, such as "class."

Hmmm... We certainly wouldn't want bolding to become "tedious."
:roll:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic