Hashtable put Example
Hashtable class put method example.public V put(K key, V value) Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.
Here is the code
/**
* @ # Put.java
* A class repersenting use to put method
* of HashMap class in java.util package
* version 19 May 2008
* author Rose India
*/
import java.util.*;
public class Put {
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);
}
} |
Output
| table :{4=D, 3=C, 2=B, 1=A} |
|