Content about Java ERP Solution for Reviews Best ERP Software for sale and Free Software with Java OpenSource for Free Download

Java hashmap get value by key example code for java hashmap

we can call method get to Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Method syntax

public V get(Object key)

Method input parameter

    key - the key whose associated value is to be returned

Method return

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Example Code for java enum valueof

        HashMap hm=new HashMap();
      hm.put("key1", "data1");
      hm.put("key2", "data2");
      String data=hm.get("key1");
      System.out.println(data);