Hashmap returns null value when using a nested hashmap as the key

时间:2015-10-06 08:49:28

标签: java string nullpointerexception hashmap

I have defined a hashmap as follows:

 private HashMap<HashMap<String,String>,String> like_map=new HashMap<HashMap<String,String>,String>();

The following operation returns a null string.

HashMap<String,String> fetch_key = new HashMap<String,String>();
fetch_key.put("Username", "Status");
String d=like_map.get(fetch_key);

Can anyone explain me why does String d return null?Thanks.

PS: I have put a value in the like_map hashmap as follows

HashMap<String,String> acctyp = new HashMap<String,String>();
acctyp.put("Username","Status");
like_map.put(acctyp, "0");

0 个答案:

没有答案
相关问题