Google News
logo
Java Collections - Interview Questions
How to iterate map?
The developer cannot directly iterate map, but, this interface has two methods that gives view set of map. These methods are :
 
Set<Map.Entry<K, V>>entrySet() : It is a method that returns a set having the entries mention in the map. These entries are generally objected, which has type Map. Entry.
Set<K>keySet() : This Java method returns a set that having the map key.
Advertisement