beyondgrader.com Logo
DemoBrowseAboutTeamLogin

Map Sum Longer Than

Geoffrey Challen // 2020.11.0

Create a public class called Summer that provides a single class method named sumLongerThan. sumLongerThan accepts a java.util.Map from String to Integer 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 passed Map is null or the length is negative, you should throw an IllegalArgumentException.

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