Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic