1+ [ ![ Build Status] ( https://travis-ci.com/mtumilowicz/java8-map-functions.svg?branch=master )] ( https://travis-ci.com/mtumilowicz/java8-map-functions )
2+ 13# java8-map-functions
24Overview of Java 8 additions to Map interface.
35
@@ -53,8 +55,7 @@ it with the given value and returns null, else returns the current value.
5355 **returns** the previous value associated with the specified key, or
5456 null if there was no mapping for the key.
5557
56- **Remark**: will put the value if the key is absent, even if the
57- value is null.
58+ **Remark**: putIfAbsent(1, null) will add an entry (supposing 1 is absent)
5859
5960* ` default V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) ` -
6061If the specified key is not already associated with a value (or is mapped
@@ -64,13 +65,13 @@ and enters it into this map unless null.
6465 **returns** the current (existing or computed) value associated with
6566 the specified key, or null if the computed value is null
6667
67- **Remark**: will put the null value even if the key is absent
68+ **Remark**: putIfAbsent(1, null) will NOT add an entry (supposing 1 is absent)
6869
6970* ` putIfAbsent ` vs ` computeIfAbsent ` : [ stackoverflow differences] ( https://stackoverflow.com/a/48184207 )
7071 * different returns,
7172 * laziness of ` computeIfAbsent ` - crucial while constructing expensive
7273 objects, for example ` new ArrayList<>() ` ,
73- * different approach to ` null `
74+ * different approach to ` null ` values (discussed above)
7475
7576* ` default boolean remove(Object key, Object value) ` - Removes the entry
7677for the specified key only if it is currently mapped to the specified value.
0 commit comments