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.
Answer Posted / 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 View All Answers
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
What does isempty () do in java?
What is difference between equal and == in java?
What is percentage in java?
What are java methods?
How to retrieve data from database in java using arraylist?
What language is java written?
What is java and why do we need it? Explain
What is used of static keyword in java?
What is use of arraylist in java?
What does || mean in code?
What is a singleton puppy?
Can a static class have a constructor java?
Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.
How do you get length in java?