Dictionary class isEmpty() method example
Dictionary class isEmpty()method example. This example shows you how to use isEmpty()method.This method Tests if this dictionary maps no keys to value.
Here is the code:-
/**
* @Program that Tests if this dictionary maps no keys to value.
* isemptyDictionary.java
* Author:-RoseIndia Team
* Date:-21-May-2008
*/
import java.util.*;
public class isemptyDictionary {
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" );
//returns true if this dictionary maps no keys to value.
boolean b=d.isEmpty();
System.out.println(b);
}
} |
Output of the program:-
| dictionary maps keys to value: false |
|