You are looking for an alternative to a general IDictionary in C # that accepts pairs (key, value).
In Java, there is a Dictionary class, which is the parent class of any class that accepts pairs (key, value).
A HashTable (which extends the dictionary) will suit your needs. It performs operations such as copying, deleting, adding, checking for an item, etc. However, while IDictionary supports the foreach loop in C #, to iterate over the HashTable in Java, you will need an Iterator.
The added benefit of HashTables is synchronization, so you don't have to worry about concurrency.
IF, however, you are looking for an asynchronous implementation, you should use a HashMap . HashMap also requires the iterator to go through it.
Undoubtedly, you also need to see how Iterator works in Java.
HashTables: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Hashtable.html
HashMaps: http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html
Iterator: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Iterator.html
source share