我想实现两个HashMaps.Below的组合是我的代码,但我无法产生我真正想要的。 我的代码的结果是:实现两个哈希映射
{{userId1=clientID1}=timestamp1}
{{userId1=clientID1, userId2=clientID2}=timestamp2, {userId1=clientID1, userId2=clientID2}=timestamp1}
其实我需要:
{{userId1=clientID1}=timestamp1},{userId2=clientID2}=timestamp2},{userId3=clientID3}=timestamp3}..}
就是一对一mapping.Can我们真的落实这一要求如果没有任何人可以提出这个办法?我会非常感谢...
public static void main (String args[])
{
HashMap map = new HashMap<String, String>();
HashMap<HashMap,String> multi = new HashMap();
map.put("userId1", "clientID1");
multi.put(map, "timestamp1");
System.out.println(multi); //gives me correct requirement
map.put("userId2", "clientID2");
multi.put(map, "timestamp2");
System.out.println(multi); //since the table is filled again a combination of values results(each time it keeps on increasing) which is not really required as per my requirement .Hope my problem is clear.please do help me ..
}
你想要做的事情对我来说没有任何意义。你能否用非代码术语来阐述你想要达到的目标,包括细节? – 2011-02-11 11:38:06
如果我没有弄错,这是什么类的发明。 – biziclop 2011-02-11 11:40:58