Hashtable size Example
Hashtable class size example.public int size() Returns the number of keys in this hashtable.
Here is the code
/**
* @ # Size.java
* A class repersenting use to Size method
* of HashMap class in java.util package
* version 19 May 2008
* author Rose India
*/
import java.util.*;
public class Size {
public static void main(String args[]) {
Hashtable table = new Hashtable();
System.out.println("Size of table :" + table.size());
//Put value into the table
table.put(1, "A");
table.put(2, "B");
table.put(3, "C");
table.put(4, "D");
System.out.println("Size of table :" + table.size());
}
} |
Output
Size of table :0
Size of table :4 |
|