Home » Tag Archives: hashtable

Tag Archives: hashtable

Java Dictionary example

In this tutorial we will discuss about dictionaries in Java. A Dictionary is an abstract class that maps keys to values. Every key is associated with a unique value and key are unique. Any non-null object can be used for either a key or a value. An attempt to insert either a null key or a null value to a ...

Read More »

Java Map Example

In this post, we feature a comprehensive Java Map Example. We will discuss about Maps in Java. A Map is an interface that maps keys to values. The keys are unique and thus, no duplicate keys are allowed. A map can provide three views, which allow the contents of the map to be viewed as a set of keys, collection ...

Read More »

Remove mapping from Hashtable example

In this example we shall show you how to remove mapping from a Hashtable, that means removing a key value pair from a Hashtable. To remove mapping from a Hashtable one should perform the following steps: Create a new Hashtable. Populate the hashtable with key value pairs, using put(K key, V value) API method of Hashtable. Invoke the remove(Object key) ...

Read More »

Remove all mappings from Hashtable example

With this example we are going to demonstrate how to remove all mappings from a Hashtable, that means removing all key value pairs from the Hashtable. In short, to remove all mappings from a Hashtable you should: Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method of Hashtable. Invoke the clear() API method ...

Read More »

Hashtable values Iterator example

This is an example of how to obtain a Hashtable values Iterator, that is an iterator of the values of the Hashtable. Obtaining a Hashtable values Iterator implies that you should: Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method of Hashtable. Invoke elements() API method of Hashtable. It returns an Enumeration of ...

Read More »

Hashtable keys Iterator example

In this example we shall show you how to obtain a Hashtable keys Iterator, that is an iterator of the keys of the Hashtable. To obtain a Hashtable keys Iterator one should perform the following steps: Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method of Hashtable. Invoke keys() API method of Hashtable. ...

Read More »

Hashtable Iterator example

With this example we are going to demonstrate how to obtain a Hashtable Iterator, that is an iterator of the key value pairs of the Hashtable. In short, to obtain an iterator of the Hashtable’s entries you should: Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method of Hashtable. Invoke the entrySet() API ...

Read More »

Get size of Hashtable example

This is an example of how to get the size of the Hashtable, that is the number of the key- value pairs that the Hashtable contains. Getting the size of the Hashtable implies that you should: Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method of Hashtable. Invoke the size() API method of ...

Read More »

Get Set view of Hashtable keys example

In this example we shall show you how to get a Set view of Hashtable keys. To get a Set view of Hashtable keys one should perform the following steps: Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method of Hashtable. Invoke keySet() API method of Hashtable. The method returns a Set that ...

Read More »

Get Collection view of Hashtable values example

With this example we are going to demonstrate how to get a Collection view of the Hashtable values. In short, to get a Collection view of the Hashtable values you should: Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method of Hashtable. Invoke values() API method of Hashtable. It returns a Collection that ...

Read More »