| Author |
how can be retrieve from any collection into our own order?
|
Rahul Noel
Ranch Hand
Joined: Jul 18, 2008
Posts: 51
|
|
Hi, How can be retrieve elements from HashMap,TreeSet,TreeMap,Hashtable... into our own order like reverse or ascending?
|
Thanks in Advance.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Use a Comparator, or make your objects Comparable, then you can sort your collection using whatever logic you like.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
That will only work for TreeMap and TreeSet. HashMap, HashSet and Hashtable are not meant to be ordered.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: how can be retrieve from any collection into our own order?
|
|
|