• 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

List

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ArrayList might be a good first choice...
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic