views:

665

answers:

3

How to use Class Dictionary in java ?

+2  A: 

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)

Narayan Raman
I know this but need implementation .
SjB
HashMap *is* an implementation of the Map interface.
Michael Borgwardt
+4  A: 

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

Use a Map implementation such as HashMap.

skaffman
This assumes he has a choice.
Robin
+1  A: 

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.

Robin
Something can be heavily used and still be obsolete
skaffman