Home » Core Java » util » Hashtable

Hashtable

java.util.Hashtable Example

In this example, we will show the range of functionality provided by the java.util.Hashtable class. Hashtable was part of the original java.util and is a concrete implementation of a Dictionary. However, with the advent of collections, Hashtable was reengineered to also implement the Map interface. Thus, Hashtable is now integrated into the Collections Framework. It is similar to HashMap, but ...

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 »

Copy all elements of Hashmap to Hashtable example

This is an example of how to copy all elements of a HashMap to a Hashtable. Coping HashMap elements to a Hashtable implies that you should: Create a new HashMap. Populate the hashmap with elements, using put(K key, V value) API method of HashMap. Create a new Hashtable. Populate the hashtable with elements, using put(K key, V value) API method ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns