Kotlinlearncs.online LogoJava
Return to List

Solve: Map Sum Longer Than

Created By: Geoffrey Challen
/ Version: 2020.11.0

Create a method named sumLongerThan. sumLongerThan accepts a Map from String to Int as its first parameter and an Int as its second. It returns the sum as an Int of the values of all of the keys that are longer than the second parameter.

For example:

If the length is negative, you should throw an IllegalArgumentException.

As a reminder, you can iterate over the values in a map like this:

Related Lessons

Stuck? You may find these lessons helpful: