Dictionary get() Method in Java with Examples Last Updated : 27 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 // Java code to illustrate the get() method import java.util.*; public class Dictionary_Demo { public static void main(String[] args) { // Creating an empty Dictionary Dictionary<Integer, String> dict = new Hashtable<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)); } } Output: Initial Dictionary is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes} The Value is: Welcomes The Value is: Geeks Program 2: Java // Java code to illustrate the get() method import java.util.*; public class Dictionary_Demo { public static void main(String[] args) { // Creating an empty Dictionary Dictionary<String, Integer> dict = new Hashtable<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)); } } Output: Initial Dictionary is: {You=30, Welcomes=25, 4=15, Geeks=20} The Value is: 20 The Value is: null Comment More infoAdvertise with us Next Article Dictionary elements() Method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions Java-Dictionary +2 More Practice Tags : JavaJava-CollectionsMisc Similar Reads Dictionary put() Method in Java with Examples The put() method of Dictionary is used to insert a mapping into the dictionary. This means a specific key along with the value can be mapped into a particular dictionary. Syntax: DICTIONARY.put(key, value) Parameters: The method takes two parameters, both are of the Object type of the Dictionary. ke 2 min read Dictionary keys() Method in Java with Examples The keys() method of Dictionary class in Java is used to get the enumeration of the keys present in the dictionary. Syntax: Enumeration enu = DICTIONARY.keys() Parameters: The method does not take any parameters. Return value: The method returns an enumeration of the keys of the Dictionary. Below pr 2 min read Dictionary size() Method in Java with Examples The size() Method of Dictionary class in Java is used to know the size of the dictionary or the number of distinct keys present in the dictionary. Syntax: DICTIONARY.size() Parameters: The method does not accept any parameters. Return Value: The method returns the number of keys present in the dicti 2 min read Dictionary elements() Method in Java with Examples The keys() method of Dictionary class in Java is used to get the enumeration of the values present in the dictionary. Syntax: Enumeration enu = DICTIONARY.elements() Parameters: The method does not take any parameters. Return value: The method returns an enumeration of the values of the Dictionary. 2 min read Collections list() method in Java with Examples The list() method of java.util.Collections class is used to return an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration. This method provides interoperability between legacy APIs that return enumerations and new APIs that requi 2 min read List add() Method in Java with Examples The List add() method adds (appends) an element to a list. It can be used for both ArrayList and LinkedList. Example of List add() Method: Java // Java program to demonstrate // ArrayList usage import java.io.*; import java.util.ArrayList; import java.util.List; class GFG { public static void main ( 3 min read Like