This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

List

 
mike cool
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey
i have a non fixed size list of main catogeries and from each catogory i will have non fixed size list of items
what i need to use for this
LinkedList or ArrayList or Vactor , ..etc?
note this list will be wriiten to desk
thx
 
Paul Santa Maria
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ArrayList might be a good first choice...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15203
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LinkedList, ArrayList, Vector are all implementations of the interface List (in the package java.util). For the functionality of the program, it doesn't really matter which implementation you use - they should all have the same behaviour (functionally).

Which one is best depends on non-functional requirements. For example, LinkedList is more efficient than ArrayList when you often want to insert elements in the middle of the list, and ArrayList is more efficient than LinkedList when looking up elements by index; Vector is synchronized, while ArrayList and LinkedList are not (which is important when writing multi-threaded programs).

If you're just trying to get your program to work (and you're not yet in the stage of optimizing it), it doesn't really matter which implementation of List you choose.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic