Java Collection Tutorial - Java EnumMap.containsValue(Object value)








Syntax

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

public boolean containsValue(Object value)

Example

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

//from   w  ww .  ja  va  2 s .  c  o  m

import java.util.EnumMap;

enum Tutorial {

   CSS, Python, PHP, Java, Javascript
};

public class Main {

   public static void main(String[] args) {
      EnumMap<Tutorial, String>  map =
              new EnumMap<Tutorial, String> (Tutorial.class);

      map.put(Tutorial.CSS, "1");
      map.put(Tutorial.Python, "2");
      map.put(Tutorial.PHP, "3");
      map.put(Tutorial.Java, "4");

      System.out.println(map);

      boolean contains = map.containsValue("1");

      System.out.println("Map contains '1':" + contains);

      contains = map.containsValue("5");

      System.out.println("Map contains '5':" + contains);

   }
}

The code above generates the following result.