Question: In JAVA given an array of string {Bob hi my name is bob, Jess hi my name is jess, Sam hello my name is sam,
In JAVA given an array of string {"Bob hi my name is bob", "Jess hi my name is jess", "Sam hello my name is sam", "Bob hi im bob"}
I want to do make it look like this
1. take the first word of each string in the array and make it the key in a dict (hashMap) (if the key repeats then append the two strings into one)
2. get the count occurrence of each word in the string
So it looks like
{'Bob": 'hi:2 , my:1, name:1, is:1, im:1, bob:2'}
{'Jess': 'hi:1 , my:1, name:1, is:1, jess:1'}
{'Sam': 'hi:1 , my:1, name:1, is:1, sam:1'}
Step by Step Solution
There are 3 Steps involved in it
Sure I will help you build a Java solution to transform the given array of strings into a dictionary HashMap where the first word of each string is the key and the value is a count of each words occur... View full answer
Get step-by-step solutions from verified subject matter experts
