• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Linkedlists vs vectors

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use real words (e.g., "to" and "for" rather than "2" and "4").
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
No, tomorrow we rule the world! With this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic