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

In HashTable I am storing null value..then what is the error it will show

2 Answers   GM General Motors,


What is local interface. How values will be passed?

0 Answers  


What is synchronization?

6 Answers   Verizon,


What event results from the clicking of a button?

0 Answers  


What’s jboss cache in short?

0 Answers  






Can we define constructors in Servlet?

3 Answers   Accenture, Opus, Wipro,


difference between applicationserver and webserver

2 Answers   SolutionNET,


Why are my checkboxes not being set from on to off?

0 Answers  


How are the elements of a cardlayout organized?

0 Answers  


How u validate date in DD/MM/YY format. and how u validate money in ur jsp

3 Answers   Ashok Leyland, Satyam, Tech Mahindra, Tomax,


What are the sequence of steps to write pub or sub model kind of application?

0 Answers   TCS,


To what value is a variable of the string type automatically initialized?

0 Answers  


Categories