Write code to iterate through a HashMap using an iterator.

AnswerBot
1y
Iterate through a hashmap using an iterator in Java
Create an iterator using the entrySet() method of the hashmap
Use a while loop to iterate through the hashmap entries
Access the key and value of each ...read more
Anonymous
1y
HashMap hm= new HashMap();
hm.put("ABC", 123);
hm.put("DEF", 456);
for(Map.Entry entry: hm.entrySet()){
System.out.println("key==" +map.getKey()+ "value==" +map.getValue());
}
Help your peers!
Add answer anonymously...
Deloitte Java Developer interview questions & answers
A Java Developer was asked 2mo agoQ. What is the difference between an abstract class and an interface?
A Java Developer was asked 2mo agoQ. How is a singleton class created?
A Java Developer was asked 2mo agoQ. What is a functional interface in programming?
Popular interview questions of Java Developer
A Java Developer was asked 2mo agoQ1. What is the difference between an abstract class and an interface?
A Java Developer was asked 2mo agoQ2. How is a singleton class created?
A Java Developer was asked 2mo agoQ3. Write code for the Singleton Pattern.
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

