1import java.util.*;
2
3class My_Dictionary
4{
5 public static void main(String[] args)
6 {
7 // creating a My HashTable Dictionary
8 Hashtable<String, String> my_dict = new Hashtable<String, String>();
9
10 // Using a few dictionary Class methods
11 // using put method
12 my_dict.put("01", "Apple");
13 my_dict.put("10", "Banana");
14
15 // using get() method
16 System.out.println("\nValue at key = 10 : " + my_dict.get("10"));
17 System.out.println("Value at key = 11 : " + my_dict.get("11"));
18
19 // using isEmpty() method
20 System.out.println("\nIs my dictionary empty? : " + my_dict.isEmpty() + "\n");
21
22 // using remove() method
23 // remove value at key 10
24 my_dict.remove("10");
25 System.out.println("Checking if the removed value exists: " + my_dict.get("10"));
26 System.out.println("\nSize of my_dict : " + my_dict.size());
27 }
28}
1Map<String, String> map = new HashMap<String, String>();
2map.put("dog", "type of animal");
3System.out.println(map.get("dog"));