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 the return type of interrupt method?

2 Answers  


what is the proxy pattern?

1 Answers  


Name three subclasses of the component class?

0 Answers  


What is the difference between RMI and Corba?

0 Answers   Infotech,


What are synchronized methods and synchronized statements?

2 Answers   Adobe,






What is ripple effect?

0 Answers  


what is an isolation level?

0 Answers  


What is the difference between the session.update() method and the session.lock() method?

0 Answers  


What is prototype?

0 Answers  


whether the connectionpooling used in struts?

2 Answers   SolutionNET,


Explain the different types of memory used by jvm?

0 Answers  


what is a dirty read?

1 Answers  


Categories