我正在尝试在 Java 中实现 Hash of Hashes of Arrays,并认为如果我将使用匿名 blah blah 会很好(我忘记了确切的术语/我不知道如何称呼它)。
HashMap<String, HashMap<String, String[]>> teams =
new HashMap<String, HashMap<String, String[]>>(){{
put("east", new HashMap<String, String[]>(){{
put("atlantic", new String[] { "bkn", "bos", "phi","tor", "ny" });
put("central", new String[] { "chi", "cle", "det", "ind", "mil" });
put("southeast", new String[] { "atl", "cha", "mia", "orl", "wsh" });
}});
put("west", new HashMap<String, String[]>(){{
put("northwest", new String[] { "den", "min", "okc", "por", "utah" });
put("pacific", new String[] { "gs", "lac", "lal", "phx", "sac" });
put("southwest", new String[] { "dal", "hou", "mem", "no", "sa" });
}});
}};
我的问题是,是否有另一种考虑可读性的实现方式,或者完全改变实现方式?我知道 java 不是正确的工具,但我的老板告诉我这样做。另外,请让我知道正确的术语。TIA