Hashtable: get(E e) : Hashtable « java.util « Java by API






Hashtable: get(E e)

  
/*
 * Output: 

Beijing is located in China

 */

import java.util.Hashtable;

public class MainClass {

  public static void main(String args[]) {

    Hashtable ht = new Hashtable();
    ht.put("Tokyo", "Japan");
    ht.put("Beijing", "China");
    ht.put("Bangkok", "Thailand");

    String city = "Beijing";
    String country = (String) ht.get(city);
    if (country != null)
      System.out.println(city + " is located in " + country);
    else
      System.out.println(city + " is not located in the hashtable");
  }
}

     

           
         
    
  








Related examples in the same category

1.new Hashtable()
2.new Hashtable < K, V > ()
3.Hashtable: clear()
4.Hashtable: clone()
5.Hashtable: contains(Object value)
6.Hashtable: containsKey(Object key)
7.Hashtable: elements()
8.Hashtable: entrySet()
9.Hashtable: isEmpty()
10.Hashtable: iterator()
11.Hashtable: keySet()
12.Hashtable: keys()
13.Hashtable: put(K key, V value)
14.Hashtable: putAll(Map t)
15.Hashtable: remove(Object key)
16.Hashtable: size()
17.Hashtable: values()