Hashtable isEmpty() in Java

isEmpty(): This method is available in java.util.Hashtable class of Java.

Syntax:

boolean java.util.Hashtable.isEmpty()

This method tests if this hashtable maps no keys to values.

Parameters: NA

Returns: true if this hashtable maps no keys to values; false otherwise.

Exceptions: NA

Approach

Java

import java.util.Hashtable;

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

        hashtable.put("Hello", 1);
        hashtable.put("World", 2);

        System.out.println(hashtable.isEmpty());

    }
}

Output:

false


No comments:

Post a Comment