Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

map multiple keys to a single value?

807600Jun 25 2007 — edited Jun 26 2007
Hi all,
I am reading "Objects first with Java"(third edition) and I am kind of stack on page 145.
I am given a little project called techsupport system which simply gets the user input from the terminal window, splits it at the spaces adds the words to a HashSet and passes it to another class which iterates trough the collection. During this each word is passed to a HashMap as a key and if a match is found it prints out the value.
My exercises are:
1. to match more than 1 word to a given response (with only one entry to the map);
2. to use 2 keys and get their mapped value only if both words present in the HashSet.

I can easily do them with conditional statements but I have no clue who to do them with a HashMap. I have been stack on this for 2 days now and would really appreciate your tips. thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2007
Added on Jun 25 2007
10 comments
6,058 views