ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
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.
	
 Question Submitted By :: Rajendra007
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
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 ?    2 Yes 1 No
Murali.25
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
what is Remote Reference Layer ?  1
Can you declare a static variable in a method?  4
Explain difference between final, finally and finalize?  2
how to transactions(Bank transactions) in business process in ejb? Photon1
What is meant by final class, methods and variables?  2
wht is customised exception? Prudential1
can we have function for truncating the sign as like abs in oracle.  1
What is the Layout for ToolBar?  1
Difference between Superclass and Subclass?  2
A abstract class extending an abstract class.Super class has both abstract and non-abstract methods.How can we implement abstract and non-abstract mehtods? Explain with snippet  3
write a progam hashmap & hashtable? IBM2
explain about casting of objects?  4
Why do we use public static with the main function in Java? Infosys7
What services that container provides?  1
What is the need of "creating and throwing an UserdefinedException" when the "Exception" class is already available?  4
Difference between ?System.out.println? and ?System.error.println?? Sai-Softech2
whats is the use of final,in which situation final can be used in the application? DNS2
Inorder to specify a container?s layout, which method is used?  1
What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet initialization " . Again interview asked what values will be initialized . what is difference between init() and init(ServletConfig config). Infinite-Computer-Solutions2
What is the argument type of main() method?  2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com