The get() method of Dictionary class is used to retrieve or fetch the value mapped by a particular key mentioned in the parameter. It returns NULL when the dictionary contains no such mapping for the key.
Syntax:
DICTIONARY.get(Object key_element)
Parameters: The method takes one parameter key_element of object type and refers to the key whose associated value is supposed to be fetched.
Return Value: The method returns the value associated with the key_element in the parameter.
Below programs are used to illustrate the working of java.util.Dictionary.get() Method:
Program 1:
| // Java code to illustrate the get() methodimportjava.util.*; ÂpublicclassDictionary_Demo {    publicstaticvoidmain(String[] args)    { Â        // Creating an empty Dictionary        Dictionary<Integer, String> dict            = newHashtable<Integer, String>(); Â        // Inserting the values into dictionary        dict.put(10, "Geeks");        dict.put(15, "4");        dict.put(20, "Geeks");        dict.put(25, "Welcomes");        dict.put(30, "You"); Â        // Displaying the Dictionary        System.out.println("Initial Dictionary is: "+ dict); Â        // Getting the value of 25        System.out.println("The Value is: "+ dict.get(25)); Â        // Getting the value of 10        System.out.println("The Value is: "+ dict.get(10));    }} | 
Initial Dictionary is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes}
The Value is: Welcomes
The Value is: Geeks
Program 2:
| // Java code to illustrate the get() methodimportjava.util.*; ÂpublicclassDictionary_Demo {    publicstaticvoidmain(String[] args)    { Â        // Creating an empty Dictionary        Dictionary<String, Integer> dict            = newHashtable<String, Integer>(); Â        // Inserting the values into dictionary        dict.put("Geeks", 10);        dict.put("4", 15);        dict.put("Geeks", 20);        dict.put("Welcomes", 25);        dict.put("You", 30); Â        // Displaying the Dictionary        System.out.println("Initial Dictionary is: "                           + dict); Â        // Getting the value of 25        System.out.println("The Value is: "                           + dict.get("Geeks")); Â        // Getting the value of 10        System.out.println("The Value is: "                           + dict.get(20));    }} | 
Initial Dictionary is: {You=30, Welcomes=25, 4=15, Geeks=20}
The Value is: 20
The Value is: null

 
                                    







