Java LinkedHashMap.get(Object key)

Syntax

LinkedHashMap.get(Object key) has the following syntax.

public V get(Object key)

Example

In the following code shows how to use LinkedHashMap.get(Object key) method.


import java.util.*;
//w w w.jav  a 2 s  .  c  om
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);

      // get key "Three"
      System.out.println(map.get("Three"));

      // get key "Five"
      System.out.println(map.get("Five"));
   }
}

The code above generates the following result.