我试图在Java中实现哈希数组哈希,并认为这将是很好,如果我将使用匿名等等等等(我忘了确切的术语/我不知道如何调用它)。Java中的哈希数组哈希
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
您是不是要找'匿名内部classes'? – SJuan76
也许你的意思是把这一个codereview.stackexchange.com – durron597
@ durron597我即将这样做,但我想知道替代品。我会更新我的问题,谢谢。 – jchips12