Properties int size() method Example Program


Returns the number of keys in this hashtable.

Program

package com.candidjava;

import java.util.Hashtable;
import java.util.Properties;

/* 
 * @author : Mohan 
 * @description : The size() method is used to get the number of keys in this hashtable.
 */
public class PropertiesSize {

	public static void main(String[] args) {
		Properties properties = new Properties();
		Hashtable ht = new Hashtable(properties);
		ht.put("1", "hari");
		ht.put("2", "anand");
		ht.put("3", "vinoth");
		ht.put("4", "mohan");
		ht.put("5", "karthick");
		System.out.println(ht);
		System.out.println("Size of the hash table is: " + ht.size());

	}

}

Output

{5=karthick, 4=mohan, 3=vinoth, 2=anand, 1=hari}
Size of the hash table is: 5

Explanation

public int size()
Returns the number of keys in this hashtable.
Specified by:
size in interface Map<K,V>
Specified by:
size in class Dictionary<K,V>
Returns:
the number of keys in this hashtable.


Related Post

Comments


©candidjava.com