Question: can iterator be used for hashmap?
Answer: Using an Iterator: Iterator is an interface in java. util package which is used to iterate through a collection. hm. entrySet() is used to retrieve all the key-value pairs called Map.