Tired of the following pattern?
Here is the elegant solution from the Java 8:
The output:
Inspired by the StackOverflow's question Java map.get(key) - automatically do put(key) and return if key doesn't exist?. Thanks for the solution to Roger Lindsjö.
value = map.get(key);
|
Java2html |
Here is the elegant solution from the Java 8:
import java.util.HashMap;
|
Java2html |
The output:
theValue
|
Inspired by the StackOverflow's question Java map.get(key) - automatically do put(key) and return if key doesn't exist?. Thanks for the solution to Roger Lindsjö.