Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fc3598f

Browse files
doc update
1 parent 9df8769 commit fc3598f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
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
24
Overview 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)` -
6061
If 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
7677
for the specified key only if it is currently mapped to the specified value.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /