putIfAbsent() – A Method Of Map Interface In Java
Previously we saw an important method of Map interface named getOrDefault(). In this post, we will see another important method named putIfAbsent(). Let’s start with an example:- package Concepts; import java.util.HashMap; import java.util.Map; public class PutIfAbsentMethodExample { public static void main(String[] args) { Map dataMap = new HashMap(); dataMap.put(101,”Amod”); dataMap.put(102,”Swati”); dataMap.put(103,”Aaditya”); dataMap.put(104,”Animesh”); // If we…
Read More “putIfAbsent() – A Method Of Map Interface In Java” »