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 Records In Collection Object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Records In Collection Object" Watch "Records In Collection Object" New topic
Author

Records In Collection Object

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 140
Hi.......
if i have ten records in my data base, but i want to get those records from the database and put those records in collection object,
my dout is which collection object is used in this scenario, and i want elements (or records) should be sorting order.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

If you want sorted, there are two options: SortedSet (implemented by TreeSet) or List (ArrayList, LinkedList) in combination with Arrays.sort.

I'd go with SortedSet unless you have duplicate records; then SortedSet is no longer an option.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Moojid Hamid
Ranch Hand

Joined: Mar 07, 2009
Posts: 120
IMO List (ArrayList, LinkedList) would be a better option *if* the only source of records is the database. When retrieving the records use the SQL order by clause and there will be no need to sort.

However if more records are added to the collection after filling it with the database records, I would say following Rob's suggestion.
 
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: Records In Collection Object
 
Similar Threads
Store records into collection
how i can create a Collection or a Map?
To extend or not to extend AbstractCollection
Not knowing how to catch Errors
How to get displayed records on current page into separate List?