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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -