I am creating a program that initially uses nested Hashtables in the format:
public static Hashtable<Integer, Map<String, String>> commonOpposites = new Hashtable<>(){{...}};
Purpose
The functionality of the nested hashtable is to hold values of 'common opposites' (antonyms for clarity). I have already structured most of the code to put values within the hashtable but I am having a difficult time figuring out how to obtain only values within the key : {key = value} format of the nested hashtable. Here is how I placed values into the table (I put them in pairs of 2 for ease of readability):
public static Hashtable<Integer, Map<String, String>> commonOpposites = new Hashtable<>(){{
put(1, Map.of("absent", "present")); put(2, Map.of("accurate", "inaccurate"));
put(3, Map.of("against", "for")); put(4, Map.of("all", "none"));
...
}};
I am not even sure if this is the best way to write code like this, however, I have tried using for loops with Entry, tried using built in functions and looked at examples like:
Map map = new HashMap();
((Map)map.get( "keyname" )).get( "nestedkeyname" );
I am not sure how I would access them, if someone could explain to me the complexities of something like this, it would mean a lot!