Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...



I have a sorting issue with a Hashmap. My constraint is that
I MUST use the Hashmap and work with existing code. I do a
database query and place the results in a Hashmap. When I
iterate thru the Hashmap, it loses the original alphabetical
sorting done by the database. So, my problem is that I must
sort the results coming out of the Hashmap which is then
placed into another class.



I have a sorting issue with a Hashmap. My constraint is that I MUST use the Hashmap and work with..

Answer / murali.25

1) Use a tree map or construct a treemap from hashmap.
2) If you have used order by in the query to DB, use LinkedHashMap
3) Have a java class with attributes corresponding to fields from the database table. Implement comparator interface.

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More Core Java Interview Questions

What is the difference between access specifiers and access modifiers in java?

0 Answers  


What is emant by API? is it related to java only or it is common for all OOPS supporting language?

3 Answers  


i need source code for income tax program using java inheritance

1 Answers  


What do you understand by soft reference?

0 Answers  


What do you understand by access specifiers in Java?

0 Answers   Genpact,


Why do we need strings in java?

0 Answers  


Is set sorted in java?

0 Answers  


Can we override static methods?

18 Answers   Bally Technologies,


in a console we r giving java <class name> if r pressing enter where it'll goes

2 Answers   CSC,


what is the difference between a threads start() and run() methods? : Java thread

0 Answers  


Write a factorial program using recursion in java?

0 Answers  


What are different types of control structures?

0 Answers  


Categories