Java Hashtable.get(Object key)

Syntax

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

public V get(Object key)

Example

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


/*w w w. j  a  va2  s  .  c  om*/

import java.util.Hashtable;

public class Main {
   public static void main(String args[]) {
      // create hash table 
      Hashtable<Integer,String> htable1 = new Hashtable<Integer,String>();      
      
      // put values in table
      htable1.put(1, "A");
      htable1.put(2, "B");
      htable1.put(3, "C");
      htable1.put(4, "from java2s.com");
      
      // get values at key 3
      System.out.println("Values at key 3 is:"+htable1.get(3)); 
   }    
}

The code above generates the following result.