Deleting a Hashtable Value in Java

Deleting an item from Hashtable is achievable with the method  remove(). This method finds and deletes the key and its associated value.

public V remove(Object key): Removes the key and its corresponding value from the Hashtable table and returns the value of the key that was deleted, otherwise null if the key is not found.
An exception nullPointerException is thrown if the key is null.

This code looks for an item with its key and removes the key-value pair from the Hashtable, and then it  displays the list before and after removal:

import java.util.Hashtable; 
import java.util.Map;

public class main{
public static void main(String[] args) {
Hashtable< String, String> ht = new Hashtable< String, String> ();
ht.put("1", "one");
ht.put("2", "two");
ht.put("3", "three");

Object obj = ht.remove("2");

System.out.println(obj + " has been removed");

System.out.println("HashSet after deletion:");

for (Map.Entry entry : ht.entrySet())
{
System.out.println("<" +entry.getKey()+", "+entry.getValue()+">");
}
}
}
Runtime:

two was deleted
HashSet after removal:
< 3, Three>
< 1, A>
References:
JavaDoc: Hashtable remove method