java.util.IdentityHashMap.containsValue() Method


Advertisements


Description

The containsValue(Object value) method is used to test whether the specified object reference is a value in this identity hash map.

Declaration

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

public boolean containsValue(Object value)

Parameters

value − This is the possible value to be checked.

Return Value

The method call returns 'true' if this map maps one or more keys to the specified object reference.

Exception

NA

Example

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

Live Demo
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 value exists at key 3 
      boolean isavailable = ihmap.containsValue(3);

      System.out.println("Is value exists at key '3': " + isavailable);
   }    
}

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

Is value exists at key '3': false

java_util_identityhashmap.htm

Advertisements