Hashtable remove Example


Hashtable class remove example.public V remove(Object key) Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Here is the code

/**
 * @ # Clear.java
 * A class repersenting use to clear method 
 * of HashMap class in java.util package
 * version 19 May 2008
 * author Rose India 
 */
import java.util.*;

public class Remove {

    public static void main(String args[]) {
        Hashtable table = new Hashtable();

        //Put value into the table
        table.put(1"A");
        table.put(2"B");
        table.put(3"C");
        table.put(4"D");

        System.out.println("table :" + table);

        //clear all maps
        table.remove(1);
        System.out.println("table :" + table);

    }
}

Output
table :{4=D, 3=C, 2=B, 1=A}
table :{4=D, 3=C, 2=B}

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US