Loop trough a HashMap <String, Integer> and if the value is something, for example, 5, then put the key in an array.

I'm not sure where to start, I'm having trouble on the "Loop trough a hashmap" part.

Thank you.

Recommended Answers

All 2 Replies

You can loop through all the keys, or loop through all the values. HashMap has methods that give you all the keys or all the values so you can loop through them. Inh this case you could loop through all the keys, checking the values that each key refers to, and saving that key if it refers to the value you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.