A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
how can be retrieve from any collection into our own order?
Joined: Jul 18, 2008
Jul 28, 2008 02:47:00
How can be retrieve elements from HashMap,TreeSet,TreeMap,Hashtable... into our own order like reverse or ascending?
Thanks in Advance.
Joined: Apr 14, 2004
Jul 28, 2008 03:03:00
Use a Comparator, or make your objects Comparable, then you can sort your collection using whatever logic you like.
Joined: Oct 27, 2005
Jul 28, 2008 08:39:00
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 - OCEEJBD 6
How To Ask Questions
How To Answer Questions
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: how can be retrieve from any collection into our own order?
search engine to search both at database and web application level
Enumeration Object problem
retrieve values randomly ?
automatic database connectivity
CMP and data retrieval
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014