Java Dictionary.get(Object key)

Syntax

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

public abstract V get(Object key)

Example

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


//w w w. ja v a 2  s.  c o 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 java2s.com");
      dict.put("2", "Cocoa");
      dict.put("6", "Coffee");
    
      // returns the elements associated with the key
      System.out.println(dict.get("6"));
   }
}

The code above generates the following result.