EnumMap containsValue(value) method in Java Last Updated : 24 Jul, 2020 Comments Improve Suggest changes Like Article Like Report The Java.util.EnumMap.containsValue(value) method in Java is used to determine whether one or more key of the map is associated with a given value or not. It takes the value as a parameter and returns True if that value is mapped by any of the keys in the EnumMap. Syntax: boolean containsValue(Object value) Parameter: The method accepts one parameter value which refers to the value whose mapping is to be checked by any of the key. Return Value: It returns true when one or more key is mapped to same value. Below programs illustrate the containsValue() method: Program 1: Java // Java program to demonstrate containsValue() method import java.util.*; // An enum of gfg ranking is created public enum rank_countries { India, United_States, China, Japan, Canada, Russia }; class Enum_map { public static void main(String[] args) { EnumMap<rank_countries, Integer> mp = new EnumMap<rank_countries,Integer>(rank_countries.class); // values are associated in mp mp.put(rank_countries.India, 72); mp.put(rank_countries.United_States, 1083); mp.put(rank_countries.China, 4632); mp.put(rank_countries.Japan, 6797); mp.put(rank_countries.Canada, 1820); // check if map contains mapping at specified key boolean ans = mp.containsValue(72); // prints the result System.out.println("Map contains 72: " + ans); } } Output: Map contains 72: true Program 2: Java // Java program to demonstrate containsValue() method import java.util.*; // An enum of gfg ranking is created public enum rank_countries { India, United_States, China, Japan, Canada, Russia }; class Enum_map { public static void main(String[] args) { EnumMap<rank_countries, Integer> mp = new EnumMap<rank_countries,Integer>(rank_countries.class); // values are associated in mp mp.put(rank_countries.India, 72); mp.put(rank_countries.United_States, 1083); mp.put(rank_countries.China, 4632); mp.put(rank_countries.Japan, 6797); mp.put(rank_countries.Canada, 1820); // check if map contains mapping at specified key boolean ans = mp.containsValue(2000); // prints the result System.out.println("Map contains 2000: " + ans); } } Output: Map contains 2000: false Create Quiz Comment A akash1295 Follow 0 Improve A akash1295 Follow 0 Improve Article Tags : Java Java-Collections Java-Functions Java-EnumMap Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References7 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers1 min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like