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 JNI?

1 Answers   Google, TCS,


How are the elements of a borderlayout organized?

0 Answers  


difference. between List and Set?

2 Answers   Campus Interaction, HCL, Infotech,


What is the purpose of the wait() method?

0 Answers  


what's the main difference between unix os and linux os?

2 Answers   TCS,






How will you pass parameters in RMI? Why do you serialize?

0 Answers  


Is System.err.println(""Statement"); is execute the output on console . Example: System.err.println("Hello JAVA");

8 Answers  


What are the diff types of exception?

0 Answers  


What is a session? Can you share a session object between different theads?

0 Answers  


Difference between swing and awt?

0 Answers  


Explain ioc concept?

0 Answers  


What is the difference between ear, jar and war file?

0 Answers  


Categories