I have created a HashMap that follows the pairing : <String, Object> 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:
Correct Absent : Present (or any related antonym) : Absent ✔️
or
Incorrect Absent : Zebra : Absent ❌
My code for creating the HashMap of <String, Object> pairs is as follows:
public static HashMap<String, Object> commonOpposites = new HashMap<>() {{
put("absent", List.of("present", "alert", "attentive")); put("accurate", "inaccurate");
}};
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!