How do you iterate in Hashmap?



How do you iterate in Hashmap?..

Answer / varun

HashMap<String, String> loans = new HashMap<String, String>();
loans.put("home loan", "citibank");
loans.put("personal loan", "Wells Fargo");

for (String key : loans.keySet()) {
System.out.println("------------------------------------------------");
System.out.println("Iterating or looping map using java5 foreach loop");
System.out.println("key: " + key + " value: " + loans.get(key));
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Advanced Java Interview Questions

What is servlet preinitialization

1 Answers   iFlex,


Define prototype?

0 Answers  


What is a policy?

0 Answers  


diff mvc1 and mvc2 wahts is mean by servlet chaining?

3 Answers   SolutionNET,


What is scalable, portability in the view of J2EE?

0 Answers  






Can you write Java code for declaration of multiple inheritance in Java ?

6 Answers   Kingshir, Oracle,


diff between jsp include directive and jsp action include?

4 Answers   SolutionNET,


Explain Life cycle of Servlet Filter.

2 Answers   InfoBrain, ITC Infotech,


What is Remote Server?

0 Answers   TCS,


What are the JSP implicit objects ?

1 Answers   eMids,


Which textcomponent method is used to set a textcomponent to the read-only state?

0 Answers  


diffrence between jsp and servelts.

6 Answers  


Categories