Question about java concurrenthashmap replace method -
i have following code
public class test{ private static final string key = "key"; public static void main(string[] a){ concurrenthashmap<string,string > map = new concurrenthashmap<string,string>(); system.out.println(map.replace(key,"1")); system.out.println(map.replace(key,"2")); } }
the output null both times. isn't supposed 1 second time?
the doc says:
replace entry key if mapped value. acts as
if ((map.containskey(key)) return map.put(key, value); else return null;
hence no, first replace doesn't put.
Comments
Post a Comment