Dictionary class remove(Object key) method example


Dictionary class remove(Object key) method example. This example shows you how to use remove(Object key) method.This method Removes the key (and its corresponding value) from this dictionary.

Here is the code:- div align="left" class="java">
/**
 * @Program that Removes the key (and its corresponding value) from the 
 * dictionary.
 * removeDictionary.java 
 * Author:-RoseIndia Team
 * Date:-21-May-2008
 */
import java.util.*;
public class removeDictionary {
public static void main(String[] args) {
Dictionary d=new Hashtable();
//Adding Elements in the HashTable
    d.put("1""RoseIndia");
    d.put("2","Harish" );
    d.put("8","Prakash" );
    System.out.println(d.get("8"));
    System.out.println(d.remove("8")+"  has been removed");
    System.out.println(d.get("8"));
    }

}

  Output of the program:-
Prakash
Prakash  has been removed
null

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

HOME | COPYRIGHT | CONTACT US