我有以下2个hashmaps,其中Message
是我创建的对象。从嵌套散列映射复制对象
HashMap<String, Message> hmA = new HashMap<>(); //A
HashMap<String, HashMap<String, Message>> hmFinal = new HashMap<>();
如果我填充hmA
具有以下
hmA.put("Albert", new Message("Albert", "[email protected]", "122-4645));
hmA.put("Anthony", new Message("Anthony", "[email protected]", "570-5214"));
hmA.put("Alphonso", new Message("Alphonso", "[email protected]", "888-5314"));
然后,添加hmA
到hmFinal
hmFinal.put("A", hmA);
现在,如果我创建一个临时的HashMap
HashMap<String, Message> tempHM = new HashMap<>();
如果我只有字母A进行搜索,如何使用hmFinal
将整个散列图hmA
复制到tempHM
?
基本上,如果用户想看到与字母A相关的散列表,我希望能够抓取所有hmA
并搜索其中的信息。
啊哈希映射。很长时间OOP – ne1410s 2014-10-01 18:10:52