| 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.
|
 |
 |
|
|
subject: Records In Collection Object
|
|
|