我想實現兩個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