Home » hashmap

Tag Archives: hashmap

Java Dictionary example

Bipartite Graph

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

Bipartite Graph

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 HashMap example

Bipartite Graph

This is an example of how to remove mapping from a HashMap, that is removing a key value pair from a HashMap. Removing mapping from a HashMap implies that you should: Create a new HashMap. Populate the hashMap with elements, with the put(K key, V value) API method of HashMap. Invoke the remove(Object key) API method of HashMap, to remove ...

Read More »

Remove all mappings from HashMap example

Bipartite Graph

This is an example of how to remove all mappings from a HashMap, that means removing all key value pairs in a HashMap. Removing all key value pairs from a HashMap implies that you should: Create a new HashMap. Populate the hashMap with elements, with the put(K key, V value) API method of HashMap. Invoke the clear() API method of ...

Read More »

HashMap Iterator example

Bipartite Graph

In this example we shall show you how to use a HashMap Iterator. To use a HashMap one should perform the following steps: Create a new HashMap. Populate the hashMap with elements, with the put(K key, V value) API method of HashMap. Invoke the entrySet() API method of the HashMap to get a Set of all the entries (key – ...

Read More »

Get size of HashMap example

Bipartite Graph

With this example we are going to demonstrate how to get the size of a HashMap, that is the number of key value pairs that the HashMap contains. In short, to the size of a HashMap you should: Create a new HashMap. Populate the hashMap with elements, with the put(K key, V value) API method of HashMap. Invoke the size() ...

Read More »

Get Set view of HashMap keys example

Bipartite Graph

This is an example of how to get a Set view of HashMap keys. Getting a Set view of HashMap keys implies that you should: Create a new HashMap. Populate the hashMap with elements, with the put(K key, V value) API method of HashMap. Invoke the keySet() API method of HashMap to get a Set containing all keys in the ...

Read More »

Check value existence in HashMap example

Bipartite Graph

In this example we shall show you how to check a value existence in HashMap. To check if a value exists in a HashMap one should perform the following steps: Create a new HashMap. Populate the hashMap with elements, with the put(K key, V value) API method of HashMap. Invoke the containsValue(Object key) API method of the HashMap with a ...

Read More »

Check key existence in HashMap example

Bipartite Graph

With this example we are going to demonstrate how to check a key existence in a HashMap. In short, to check if a key exists in a HashMap you should: Create a new HashMap. Populate the hashMap with elements, with the put(K key, V value) API method of HashMap. Invoke the containsKey(Object key) API method of the HashMap. The method ...

Read More »