HashMap with Objects
I have created a HashMap that follows the pairing : and it functions as a data holder for most of the String: Object pairs I intend to add into it.
Purpose
I am creating a program that allows user input on determining whether a certain word is the correct opposite (antonym which is inputted by the user). For example, I would request the user to input the opposite of
absent
; The possibilities are as follows:
1.
or
2.
My code for creating the HashMap of <String, Object> pairs is as follows:
Question
How would I access anything within the List reference? If I were to check if user input is in fact one of the elements within the List, would I use contains()
within a if statement?
I appreciate all the help and support for anyone who can look into this!6 Replies
Hey, @verbose!
Please remember to
/close
this post once your question has been answered!don't use
Object
but List<String>
as values
so Map<String, List<String>>
I would use that but the purpose of having
<String, Object>
is so that I wont need to add a list when working with only 1 opposite such as zip - unzip
(there would be no purpose of having a list of just 1 element)just use a list with a single element
makes stuff easier
I guess you maybe right
Post Closed
This post has been closed by <@400463761011507212>.