Remove Elements

  1. remove(key) - returns and removes the entry associated with the specified key from the map.
  2. remove(key, value) - removes the entry from the map only if the specified key mapped to the specified value and return a boolean value.


\begin{lstlisting}
import java.util.HashMap;
\par
class Main {
public static vo...
...t );
System.out.println(''Updated HashMap: '' + numbers);
}
}
\end{lstlisting}

Output


\begin{lstlisting}
HashMap : { One =1 , Two =2 , Three =3}
Removed value : 2
Is the entry Three removed ? True
Updated HashMap : { One =1}
\end{lstlisting}