Menu
Question Index
...


Write a program to create a hash map of character and the list of words containing it from a given sentence.

Input (String) Output (Hash Map)
Sun raises in the east {u=>[Sun], t=>[the, east], e=>[raises, the, east], r=>[raises], S=>[Sun, raises, east], a=>[raises, east], n=>[Sun, in], h=>[the], i=>[raises, in]}
How are you? {w=>[How], u=>[you], e=>[are], r=>[are], a=>[are], o=>[How, you], H=>[How], y=>[you]}
How do you do? {w=>[How], u=>[you], d=>[do, do], o=>[How, do, you, do], H=>[How], y=>[you]}
All the best {e=>[the, best], t=>[the, best], s=>[best], b=>[best], A=>[All], l=>[All], h=>[the]}

class CreateCharacterHashMap

{    public static void main(String s[])
    {
        System.out.println("The resultant hash map is : " + createCharacterWordsMap("Hello how are you?"));

    }


public static Map<Character, List<String>> createCharacterWordsMap(String sentence) {
//Write code here to create a hash map of character and the list of words containing it from given sentence
}

//Use this to create other methods if required.
}

Doubts

Problems

Topic: Advanced Java Programming Concepts

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App