ConcurrentSkipListMap remove() method in Java with Examples
The remove() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which removes the mapping for the specified key from this map. The method returns null if there is no mapping for of that particular key. After this method is performed the size of the map is reduced.
Syntax:
ConcurrentSkipListMap.remove(Object ob)
Parameter: The function accepts a single mandatory parameter ob which specifies the key whose mapping is to be removed.
Return Value: The function returns the previous value associated with the specified key, or null if there was no mapping for the key.
Below programs illustrate the above method:
// Java Program Demonstrate remove() // method of ConcurrentSkipListMap import java.util.concurrent.*; class GFG { public static void main(String[] args) { // Initializing the map ConcurrentSkipListMap<Integer, Integer> mpp = new ConcurrentSkipListMap<Integer, Integer>(); // Adding elements to this map for (int i = 1; i <= 5; i++) mpp.put(i, i); // remove() operation on the map mpp.remove(1); System.out.println("After remove(): " + mpp); } } |
After remove(): {2=2, 3=3, 4=4, 5=5}
Program 2:
// Java Program Demonstrate remove() // method of ConcurrentSkipListMap import java.util.concurrent.*; class GFG { public static void main(String[] args) { // Initializing the map ConcurrentSkipListMap<Integer, Integer> mpp = new ConcurrentSkipListMap<Integer, Integer>(); // Adding elements to this map for (int i = 1; i <= 5; i++) mpp.put(i, i); // remove() operation on the map mpp.remove(5); System.out.println("After remove(): " + mpp); } } |
After remove(): {1=1, 2=2, 3=3, 4=4}
Recommended Posts:
- ConcurrentSkipListMap put() method in Java with Examples
- ConcurrentSkipListMap containsKey() method in Java with Examples
- ConcurrentSkipListMap containsValue() method in Java with Examples
- ConcurrentSkipListMap equals() method in Java with Examples
- ConcurrentSkipListMap clone() method in Java with Examples
- ConcurrentSkipListMap ceilingKey() method in Java with Examples
- ConcurrentSkipListMap clear() method in Java with Examples
- ConcurrentSkipListMap size() method in Java with Examples
- ConcurrentSkipListMap isEmpty() method in Java with Examples
- Set remove() method in Java with Examples
- Map remove() Method in Java with Examples
- AbstractSequentialList remove() method in Java with Examples
- ConcurrentLinkedDeque remove() method in Java with Examples
- CopyOnWriteArrayList remove() method in Java with Examples
- AbstractCollection remove() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



