Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures Efficiency! Design the UI

Jan Kalasnikov
Jan Kalasnikov
7,167 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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 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.

Thanks