Sajad Bahmani
Sajad Bahmani

Reputation: 17469

Class Dictionary in java (data structure)

How to use Class Dictionary in java ?

Upvotes: 1

Views: 3111

Answers (3)

Robin
Robin

Reputation: 24282

You can use a Hashtable. It extends the Dictionary class.

As for everyone who says it is obsolete, it probably should be but isn't. It is used in the current OSGi api in the class ServiceRegistration, and OSGi is somewhat popular these days ;-)

Of course, since Hashtable also implements Map, at least you can treat as one in your own code and still pass it in via the OSGi api as needed.

Upvotes: 1

skaffman
skaffman

Reputation: 403581

Don't use it, it's profoundly, thoroughly, obsolete and unnecessary.

Use a Map implementation such as HashMap.

Upvotes: 6

Narayan Raman
Narayan Raman

Reputation: 891

Look at java.util.HashMap and java.util.Map (I understand you are looking for a dictionary equivalent in Java, and not referring to the abstract Dictionary class which is implemented by HashTable)

Upvotes: 2

Related Questions