Kotlinlearncs.online LogoJava
Return to List

Homework: Word Count With Map

Created By: Geoffrey Challen
/ Version: 2021.9.0

Given a non-null String containing words separated by the "_" character, write a method wordCount that return a Map<String, Integer> containing the number of times that each part appears in the String.

So, for example, given the String "Xyz_Chuchu_Chuchu_Xyz_Ferdie", you would return a map with three mappings: "Xyz" to 2, "Chuchu" to 2, and "Ferdie" to 1.

Related Lessons

Stuck? You may find these lessons helpful: