Java Dictionary() Constructor
Syntax
Dictionary() constructor from Dictionary has the following syntax.
public Dictionary()
Example
In the following code shows how to use Dictionary.Dictionary() constructor.
//from w w w .ja v a2 s . c o m
import java.util.*;
public class Main {
public static void main(String[] args) {
// Create a new hasthtable
Dictionary d = new Hashtable();
// Put some elements
d.put("1", "from java2s.com");
d.put("2", "Cocoa");
d.put("5", "Coffee");
// print the size of the dictionary
System.out.println("Size of dictionary:" + d.size());;
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »