Java Java Data Structures Efficiency! Design the UI

Jan Kalasnikov
Jan Kalasnikov
3,051 Points

what does entrySet() means?

Hey guys im lost with the HasMap and method entrySet(). Can someone explain it briefly? Thanks!

1 Answer

Tonnie Fanadez
Tonnie Fanadez
UX Design Techdegree Student 15,213 Points

Hello Jan Kalasnikov

entrySet() method is from the Map Interface.

When called on a Map<Key,Value> object it returns a Set<> Object containing all the keys and values.

You can then easily iterate on the returned Set<> object using the for-each loop and an object of type Map.Entry<Key, Value> will be returned with each iteration. You can then use the Map.Entry<Key, Value> to get the key and the value for each entry on the Map.