Check if a particular value exists in Java HashMap example : HashMap « Collections Data Structure « Java






Check if a particular value exists in Java HashMap example

      

import java.util.HashMap;

public class Main {
  public static void main(String[] args) {
    HashMap<String, String> hMap = new HashMap<String, String>();

    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    System.out.println(hMap.containsValue("Two"));
  }
}

   
    
    
    
    
    
  








Related examples in the same category

1.Iterate through the values of Java HashMap example
2.Get Synchronized Map from Java HashMap example
3.Check if a particular key exists in Java HashMap example
4.Get Set view of Keys from Java HashMap example
5.Get Size of Java HashMap
6.Remove all values from Java HashMap example
7.Remove value from Java HashMap
8.Create Java Hashtable from HashMap
9.Sort an HashMap based on the keys
10.For keys of a map
11.For values of a map
12.For both the keys and values of a map
13.Storing Primitive Types in a Collection
14.Creating a Copy of a Collection: the objects are not cloned.
15.Use Iterator to loop through the map key set
16.Generic hashmap with String as key and Integer as valueGeneric hashmap with String as key and Integer as value
17.Get key set and value set from map and use Iterator to loop through them
18.Clones a map
19.Hash map for counting references to Object keys.
20.Extended Version of java.util.HashMap that provides an extended get method accpeting a default value.
21.Compact HashMap
22.This class wraps a HashMap and provides methods by which key objects can be associated with "counting" values.
23.This extension of HashMap support duplicate keys
24.Concurrent Hopscotch HashMap