HashTable boolean isEmpty() Method Example Program


Tests if this hashtable maps no keys to values.

Program

package com.candidjava;

import java.util.Hashtable;

/**
 * @author: Hari Haran
 * @discription: The isEmpty() method is used to test if this hashtable maps no
 *               keys to values.
 */

public class HashTableIsEmpty {
	public static void main(String args[]) {
		Hashtable<Integer, String> ht1 = new Hashtable<Integer, String>();

		ht1.put(1, "Anand");
		ht1.put(2, "Hari Haran");
		ht1.put(3, "Kamal");
		ht1.put(4, "Karthikeyan");
		ht1.put(5, "Mohan");
		ht1.put(6, "Vinoth");
		ht1.put(7, "Hari Haran");

		System.out.println("Is hash table empty :" + ht1.isEmpty());
	}
}

Output

Is hash table empty :false

Explanation

public boolean isEmpty()
Tests if this hashtable maps no keys to values.
Specified by:
isEmpty in interface Map<K,V>
Specified by:
isEmpty in class Dictionary<K,V>
Returns:
true if this hashtable maps no keys to values; false otherwise.


Related Post

Comments


©candidjava.com