Question
Java programming 1)Read all words from a file and add them to a map whose keys are the first letters of the words and whose
Java programming
1)Read all words from a file and add them to a map whose keys are the first letters of the words and whose values are sets of words that start with that same letter. Then print out the word sets in alphabetical order.
Sample input file: She took down a jar from one of the shelves as she passed; it was labelled 'ORANGE MARMALADE', but to her great disappointment it was empty.
Output:
a: [a, as]
b: [but]
d: [disappointment, down]
e: [empty]
f: [from]
g: [great]
h: [her]
i: [it]
j: [jar]
l: [labelled]
m: [marmalade]
o: [of, one, orange]
p: [passed]
s: [she, shelves]
t: [the, to, took]
w: [was]
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