Java Dictionary.put(K key, V value)
Syntax
Dictionary.put(K key, V value) has the following syntax.
public abstract V put(K key, V value)
Example
In the following code shows how to use Dictionary.put(K key, V value) method.
/* w ww. ja va 2 s. co m*/
import java.util.*;
public class Main {
public static void main(String[] args) {
Dictionary d = new Hashtable();
// put some elements
d.put("1", "from java2s.com");
d.put("2", "Cocoa");
d.put("5", "Coffee");
// print how many times put was called
System.out.println("Number of times put was called:" + d.size());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »