X470: Hashmaps - Get from Map

The method mapNums returns a HashMap that stores values of how many times a given key digit has appeared in an input String. Write a method that calls mapNums and returns the number of times an input digit appeared in an input String. Note that if a digit did not appear, it won't be an existing key.

Examples:

getFromMap("asd27fghjk1234477", 3) ->  1
getFromMap("asd27fghjk1234477", 4) -> 2
getFromMap("asd27fghjk1234477", 5) -> 0
getFromMap("asd27fghjk1234477", 7) -> 3

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.