IdentityHashMap remove Example
IdentityHashMap class remove example. This example shows you how to use remove method.
IdentityHashMap class remove example. public Map remove(Object) Removes the mapping for this key from this map if present.
Here is the code
/**
* @ # Remove.java
* A class repersenting use to remove method
* of IdentityHashMap class in java.util package
* version 26 May 2008
* author Rose India
*/
import java.util.*;
public class Remove {
public static void main(String args[]) {
IdentityHashMap map = new IdentityHashMap();
//Add the mapping into the map
map.put(1, "A");
map.put(2, "A");
map.put(3, "B");
System.out.println("Map " + map);
System.out.println("Removed object " + map.remove(1));
System.out.println("Map " + map);
}
} |
Output
Map {2=A, 1=A, 3=B}
Removed object A
Map {2=A, 3=B}
|
|