
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Importance of a Dictionary class in Java?
A Dictionary class is an abstract class that represents a key/value pair and operates like a Map and it is a legacy class in Java. A Dictionary class has two important methods Dictionary.keys() and Dictionary.elements() that can be iterated by an Enumeration. The other important methods of a Dictionary class are isEmpty(), get(), remove() and size().
Syntax
public abstract class Dictionary<K,V> extends Object
Example
import java.util.*; public class DictionaryTest { public static void main(String[] args) { Dictionary<Integer, String> dic = new Hashtable<Integer, String>(); dic.put(1, "Adithya"); dic.put(2, "Jaidev"); dic.put(3, "Raja"); Enumeration<Integer> key = dic.keys(); while(key.hasMoreElements()) { System.out.println(key.nextElement()); } Enumeration<String> element = dic.elements(); while(element.hasMoreElements()) { System.out.println(element.nextElement()); } } }
Output
3 2 1 Raja Jaidev Adithya
- Related Articles
- Importance of a Locale class in Java?
- Importance of StringReader class in Java?\n
- Importance of MethodHandles class in Java 9?
- What is the importance of a Cursor class in Java?
- What is the importance of a SwingWorker class in Java?\n
- What is the importance of SwingUtilities class in Java?
- What is the importance of Runtime class in Java?
- What is the importance of JViewport class in Java?
- What is the importance of JSeparator class in Java?
- What is the importance of Boolean class in Java?\n
- What is the importance of the GridBagConstraints class in Java?
- What is the importance of the CardLayout class in Java?
- What is the importance of the Container class in Java?
- Dictionary Class in C#
- What is the importance of the Throwable class and its methods in Java?

Advertisements