File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "List" Watch "List" New topic


mike cool

Joined: Oct 21, 2005
Posts: 24
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
Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
ArrayList might be a good first choice...

Paul M. Santa Maria, SCJP
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: List
It's not a secret anymore!