File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes order in a collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "order in a collection" Watch "order in a collection" New topic
Author

order in a collection

Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
I am looking for a Collection that guarentees that the order in which I place objects will be maintained. Does anyone have any suggestions?


Matthew Phillips
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Nevermind. It looks like an ArrayList will fit my needs perfectly.
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
all collections that use the List interace accomplish just that. ArrayList is the best one in my opinon too although LinkedList does the same.
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Originally posted by Roy Ben Ami:
all collections that use the List interace accomplish just that. ArrayList is the best one in my opinon too although LinkedList does the same.

Right. I decided on the ArrayList because I am not going to be inserting objects in the beginning or deleting objects from an iterator. It has been awhile since I have worked with any of the Collections so I couldn't remember which interface featured guaranteed order.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: order in a collection
 
Similar Threads
Which collection class would you use to store the objects?
Regarding Collections
Representing collections in UML
About Hashtable
sorting a TreeMap