Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes List Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "List" Watch "List" New topic
Author

List

mike cool
Greenhorn

Joined: Oct 21, 2005
Posts: 24
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

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


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

Joined: Aug 16, 2005
Posts: 12907
    
    3

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 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: List
 
Similar Threads
why is the ListCellRendererComponent called twice for every list item
Increasing Array Size
Dynamic String Array Decelaration
Split String to ArrayList
generics 1.4