Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ArrayList question

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello;

I have a couple of questions about the ArrayList collection.

1. Are they kept in a sorted order?
2. If they aren't, is it possible to keep one sorted? while inserting objects?

Thanks!



 
No the ArrayList is not guaranteed to be in sorted order. It will be in whatever order the items are entered. You can always sort an ArrayList though. If you want a Collection that has guaranteed sorted order (when accessed the proper way using an Iterator) then you should look to using a SortedSet. Of course a SortedSet has the added restriction of not allowing duplicate entries.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top