Java Collection Tutorial - Java Dictionary.get(Object key)


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

public abstract V get(Object key)


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

//from w  w  w .  j ava 2  s  .  co  m
import java.util.*;

public class Main {

   public static void main(String[] args) {

      Dictionary dict = new Hashtable();
      // add elements in the hashtable
      dict.put("1", "from");
      dict.put("2", "Cocoa");
      dict.put("6", "Coffee");
      // returns the elements associated with the key

The code above generates the following result.