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

If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?

0 Answers  


How do you remove an element from an arraylist in java?

0 Answers  


What is final keyword in java? Give an example.

0 Answers  


What is the purpose of garbage collection in java, and when is it used?

0 Answers  


What is the purpose of a default constructor?

0 Answers  


write a program to create an vector and listeterator.and value should be enter through keyboard.

1 Answers   Axcend,


Are generics important java?

0 Answers  


Why string is a class?

0 Answers  


Explain where variables are created in memory?

0 Answers  


What is string :: npos?

0 Answers  


Is alive method in java?

0 Answers  


what is web.xml?and its use?

7 Answers   CTS,


Categories