java.util.IdentityHashMap.isEmpty() Method


Description

The isEmpty() method is used to test if this identity hash map contains no key-value mappings.

Declaration

Following is the declaration for java.util.IdentityHashMap.isEmpty() method.

public boolean isEmpty()

Parameters

NA

Return Value

The method call returns 'true' if this identity hash map contains no key-value mappings.

Exception

NA

Example

The following example shows the usage of java.util.IdentityHashMap.isEmpty()

package com.tutorialspoint;

import java.util.*;

public class IdentityHashMapDemo {
   public static void main(String args[]) {

      // create identity hash map
      IdentityHashMap ihmap = new IdentityHashMap();

      // populate the map
      ihmap.put(1, "java");
      ihmap.put(2, "util");
      ihmap.put(3, "package");

      // check if map is empty
      boolean isempty = ihmap.isEmpty();

      System.out.println("Is the map empty: " + isempty);
   }    
}

Let us compile and run the above program, this will produce the following result.

Is the map empty: false
java_util_identityhashmap.htm
Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements