elements(): This method is available in java.util.Dictionary class of Java.
Syntax:
Enumeration<Integer> java.util.Dictionary.elements()
This method returns an enumeration of the values in this dictionary.
Parameters: NA
Returns: an enumeration of the values in this dictionary.
Exceptions: NA
Approach
Java
import java.util.Dictionary;import java.util.Enumeration;import java.util.Hashtable;public class Dictionaryelements {public static void main(String[] args) {Dictionary<String, Integer> dictionary =new Hashtable<String, Integer>();dictionary.put("Hello", 10);dictionary.put("Java", 4);dictionary.put("C++", 17);Enumeration<Integer> enumeration = dictionary.elements();while (enumeration.hasMoreElements())System.out.print(enumeration.nextElement() + " ");}}
Output:
4 17 10
No comments:
Post a Comment