2013年10月7日星期一

How to remove and modify the values ??

HashMap
HashMap<String, Integer> hm=new HashMap<String, Integer>();
int i=hm.get("abc");
i++;

This does not modify the "abc" corresponding value , is there any way you
------ Solution -------------------- ------------------------


direct coverage on the line, use the put (key, value) method override
------ Solution ----------------------- ---------------------
HashMap hm = new HashMap ();
int i = hm.get ("abc");
hm.put ("abc", i + +);

没有评论:

发表评论