# Dictionary

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/java/util/Dictionary#pubctors)\|[Methods](https://developer.android.com/reference/java/util/Dictionary#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/Dictionary#inhmethods)  

# Dictionary

`
public


abstract
class
Dictionary
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.util.Dictionary\<K, V\> |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [Hashtable](https://developer.android.com/reference/java/util/Hashtable)\<K, V\> |----------------------------------------------------------------------------------|----------------------------------------------------------------| | [Hashtable](https://developer.android.com/reference/java/util/Hashtable)\<K, V\> | This class implements a hash table, which maps keys to values. | |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [AuthProvider](https://developer.android.com/reference/java/security/AuthProvider),[Properties](https://developer.android.com/reference/java/util/Properties),[Provider](https://developer.android.com/reference/java/security/Provider) |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | [AuthProvider](https://developer.android.com/reference/java/security/AuthProvider) | Legacy security code; do not use.                                                                                             | | [Properties](https://developer.android.com/reference/java/util/Properties)         | The`Properties`class represents a persistent set of properties.                                                               | | [Provider](https://developer.android.com/reference/java/security/Provider)         | This class represents a "provider" for the Java Security API, where a provider implements some or all parts of Java Security. | |

<br />

*** ** * ** ***

The`Dictionary`class is the abstract parent of any class, such as`Hashtable`, which maps keys to values. Every key and every value is an object. In any one`Dictionary`object, every key is associated with at most one value. Given a`Dictionary`and a key, the associated element can be looked up. Any non-`null`object can be used as a key and as a value.

As a rule, the`equals`method should be used by implementations of this class to decide if two keys are the same.

**NOTE: This class is obsolete. New implementations should implement the Map interface, rather than extending this class.**  
**See also:**

- [Map](https://developer.android.com/reference/java/util/Map)
- [Object.equals(java.lang.Object)](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))
- [Object.hashCode()](https://developer.android.com/reference/java/lang/Object#hashCode())
- [Hashtable](https://developer.android.com/reference/java/util/Hashtable)

## Summary

|                                               ### Public constructors                                                ||
|-------------------------------------------------------------------------------------------------------------------|---|
| ` `[Dictionary](https://developer.android.com/reference/java/util/Dictionary#Dictionary())`() ` Sole constructor. |

|                                                                                                                                                                 ### Public methods                                                                                                                                                                  ||
|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract `[Enumeration](https://developer.android.com/reference/java/util/Enumeration)`<V>` | ` `[elements](https://developer.android.com/reference/java/util/Dictionary#elements())`() ` Returns an enumeration of the values in this dictionary.                                                                                                 |
| ` abstract V`                                                                                 | ` `[get](https://developer.android.com/reference/java/util/Dictionary#get(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` key) ` Returns the value to which the key is mapped in this dictionary.           |
| ` abstract boolean`                                                                           | ` `[isEmpty](https://developer.android.com/reference/java/util/Dictionary#isEmpty())`() ` Tests if this dictionary maps no keys to value.                                                                                                            |
| ` abstract `[Enumeration](https://developer.android.com/reference/java/util/Enumeration)`<K>` | ` `[keys](https://developer.android.com/reference/java/util/Dictionary#keys())`() ` Returns an enumeration of the keys in this dictionary.                                                                                                           |
| ` abstract V`                                                                                 | ` `[put](https://developer.android.com/reference/java/util/Dictionary#put(K,%20V))`(K key, V value) ` Maps the specified`key`to the specified`value`in this dictionary.                                                                              |
| ` abstract V`                                                                                 | ` `[remove](https://developer.android.com/reference/java/util/Dictionary#remove(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` key) ` Removes the`key`(and its corresponding`value`) from this dictionary. |
| ` abstract int`                                                                               | ` `[size](https://developer.android.com/reference/java/util/Dictionary#size())`() ` Returns the number of entries (distinct keys) in this dictionary.                                                                                                |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Dictionary

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Dictionary ()
```

Sole constructor. (For invocation by subclass constructors, typically implicit.)

<br />

## Public methods

### elements

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Enumeration<V> elements ()
```

Returns an enumeration of the values in this dictionary. The general contract for the`elements`method is that an`Enumeration`is returned that will generate all the elements contained in entries in this dictionary.

<br />

|                                                                  Returns                                                                   ||
|-----------------------------------------------------------------------------------|---------------------------------------------------------|
| [Enumeration](https://developer.android.com/reference/java/util/Enumeration)`<V>` | an enumeration of the values in this dictionary. <br /> |

**See also:**

- [keys()](https://developer.android.com/reference/java/util/Dictionary#keys())
- [Enumeration](https://developer.android.com/reference/java/util/Enumeration)  

### get

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract V get (Object key)
```

Returns the value to which the key is mapped in this dictionary. The general contract for the`isEmpty`method is that if this dictionary contains an entry for the specified key, the associated value is returned; otherwise,`null`is returned.

<br />

|                                                    Parameters                                                    ||
|-------|-----------------------------------------------------------------------------------------------------------|
| `key` | `Object`: a key in this dictionary.`null`if the key is not mapped to any value in this dictionary. <br /> |

|                               Returns                                ||
|-----|-----------------------------------------------------------------|
| `V` | the value to which the key is mapped in this dictionary; <br /> |

|                                                        Throws                                                        ||
|------------------------------------------------------------------------------------------------|----------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the`key`is`null`. |

**See also:**

- [put(java.lang.Object, java.lang.Object)](https://developer.android.com/reference/java/util/Dictionary#put(K,%20V))  

### isEmpty

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean isEmpty ()
```

Tests if this dictionary maps no keys to value. The general contract for the`isEmpty`method is that the result is true if and only if this dictionary contains no entries.

<br />

|                                       Returns                                       ||
|-----------|--------------------------------------------------------------------------|
| `boolean` | `true`if this dictionary maps no keys to values;`false`otherwise. <br /> |

### keys

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Enumeration<K> keys ()
```

Returns an enumeration of the keys in this dictionary. The general contract for the keys method is that an`Enumeration`object is returned that will generate all the keys for which this dictionary contains entries.

<br />

|                                                                 Returns                                                                  ||
|-----------------------------------------------------------------------------------|-------------------------------------------------------|
| [Enumeration](https://developer.android.com/reference/java/util/Enumeration)`<K>` | an enumeration of the keys in this dictionary. <br /> |

**See also:**

- [elements()](https://developer.android.com/reference/java/util/Dictionary#elements())
- [Enumeration](https://developer.android.com/reference/java/util/Enumeration)  

### put

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract V put (K key, 
                V value)
```

Maps the specified`key`to the specified`value`in this dictionary. Neither the key nor the value can be`null`.

If this dictionary already contains an entry for the specified`key`, the value already in this dictionary for that`key`is returned, after modifying the entry to contain the new element.

If this dictionary does not already have an entry for the specified`key`, an entry is created for the specified`key`and`value`, and`null`is returned.

The`value`can be retrieved by calling the`get`method with a`key`that is equal to the original`key`.

<br />

|               Parameters                ||
|---------|--------------------------------|
| `key`   | `K`: the hashtable key. <br /> |
| `value` | `V`: the value. <br />         |

|                                                              Returns                                                               ||
|-----|-------------------------------------------------------------------------------------------------------------------------------|
| `V` | the previous value to which the`key`was mapped in this dictionary, or`null`if the key did not have a previous mapping. <br /> |

|                                                            Throws                                                             ||
|------------------------------------------------------------------------------------------------|-------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the`key`or`value`is`null`. |

**See also:**

- [Object.equals(java.lang.Object)](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))
- [get(java.lang.Object)](https://developer.android.com/reference/java/util/Dictionary#get(java.lang.Object))  

### remove

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract V remove (Object key)
```

Removes the`key`(and its corresponding`value`) from this dictionary. This method does nothing if the`key`is not in this dictionary.

<br />

|                        Parameters                         ||
|-------|----------------------------------------------------|
| `key` | `Object`: the key that needs to be removed. <br /> |

|                                                        Returns                                                        ||
|-----|------------------------------------------------------------------------------------------------------------------|
| `V` | the value to which the`key`had been mapped in this dictionary, or`null`if the key did not have a mapping. <br /> |

|                                                      Throws                                                      ||
|------------------------------------------------------------------------------------------------|------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if`key`is`null`. |

### size

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int size ()
```

Returns the number of entries (distinct keys) in this dictionary.

<br />

|                       Returns                        ||
|-------|-----------------------------------------------|
| `int` | the number of keys in this dictionary. <br /> |