Dictionary class in java.util: Methods

A dictionary is an object having key and value pair of objects. A key is always unique in a map and is used to find the value. Dictionary is an abstract class and it works just like a Map class. Methods defined by Dictionary class:

remove( ) method: It is used to remove an entry which has key as k.


Object remove(Object k)

size( ) method: It is used to return the number of key and value pairs in calling dictionary.


int size( )

get( ) method: It is used to return value of a key.


Object get(Object k)

put( ) method: It is used to put an entry in calling dictionary. The previous values will be overwritten.


Object put(Object k, Object val)

isEmpty( ) method: It returns true if calling dictionary is empty, otherwise false.


boolean isEmpty( )

elements( ) method: It is used to return enumeration of elements in a dictionary.


Enumeration elements( )

keys( ) method: It is used to return an enumeration of keys in dictionary.


Enumeration keys( )

Leave a Reply