Question
a method named characterCounts that takes a String and returns back a map of counts of the number of times each character appears in the
a method named characterCounts that takes a String and returns back a map of counts of the number of times each character appears in the String. Your solution can ONLY use Map and String methods.
For example, after the following code segment:
// str is "abcbadebdd" Map counts = characterCounts(str);
Should set the value of counts to be:
// counts is a map containing { ('a', 2), ('c', 1), ('d', 3), ('b', 3), ('e',1) }/* Return a map of counts of the characters in a string * * @param str String to count chars in * @return map containing the counts of the chars in str */ public static Map characterCounts(String str) { // TODO: Your code below this line }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started