Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
List list = List.of("Apple","Papaya","Orange");

output :

{Apple={p=2, a=1, e=1, l=1}, Papaya={p=2, a=3, y=1}, Orange={a=1, r=1, e=1, g=1, n=1, o=1}}

What I have tried:

I have got the solution without using stream api.
Posted
Updated 20-Oct-22 19:23pm
Comments
Dave Kreskowiak 20-Oct-22 8:16am    
Your question as asked is unanswerable. You give no details at all on how you are supposed to get from a list of three strings to whatever that output is supposed to be.
OriginalGriff 20-Oct-22 8:37am    
And?
What have you tried?
Where are you stuck?
What help do you need?

Use the "Improve question" widget to edit your question and provide better information.

Map<string, map<character,integer="">> countMap = new HashMap();
for (String s : list) {
char[] c = s.toCharArray();
Map<character,integer> insideMap= new HashMap<>();

for (char ele : c) {
char lowerCase = Character.toLowerCase(ele);
insideMap.merge(lowerCase, 1, Integer::sum);
countMap.put(s, insideMap);
}

}

this it can be resolve , but I have no idea how I can use collector grouping by functionality.
since the output should be Map of map, I am not able to resolve using stream api with the combination of collectors.groupingBy
 
Share this answer
 
Comments
Richard Deeming 21-Oct-22 3:56am    
In what way is this supposed to be a solution to your question?!

If you want to update your question to add missing information, click the green "Improve question" link and edit your question. Do not post the update as a "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900