3:42 pm - Thursday November 18, 1688

Hashtable Example program for size()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
Author :candidjava.com
Description: Returns the number of keys in this hashtable.
 */
import java.util.*;
import java.util.Hashtable;
import java.io.IOException;

public class HashtableSizeExample {
	public static void main(String args[]) throws IOException {
		int i;
		Hashtable h = new Hashtable();
		h.put(1, 11);
		h.put(2, 22);
		h.put(3, 33);
		h.put(5, 35);
		i = h.size(); // return the size of values and keys in the hashtable
		System.out.println(i);
	}
}

Output
4

Filed in: Z-A All Java Codes

Comments are closed.