This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
Consider Paul's rocket mass heater.
 
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