Java LinkedHashMap .containsValue ( Object value)

Syntax

LinkedHashMap.containsValue(Object value) has the following syntax.

public boolean containsValue(Object value)

Example

In the following code shows how to use LinkedHashMap.containsValue(Object value) method.


/* w  ww .j ava  2s. c  om*/
import java.util.*;

public class Main {

   public static void main(String[] args) {

      LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>(5);

      // add some values in the map
      map.put("One", 1);
      map.put("Two", 2);
      map.put("Three", 3);

      System.out.println(map);

      // check if map contains 3
      System.out.println(map.containsValue(3));

      // check if map contains 5
      System.out.println(map.containsValue(5));
   }
}

The code above generates the following result.