Javatpoint Logo
Javatpoint Logo

Java IdentityHashMap put() method

The put(K key, V value) method of the Java IdentityHashMap class is used to link the specified key with a specified value in the calling IdentityHashMap.

Syntax

Parameters

Key - The key with which the specified value is to be linked.

Value - The value which is to be linked with the specified key.

Return

The previous value associated with the key or null if there was no linkage for the specified key.

Example 1

Test it Now

Output:

null
null
12
null
null
4
null
null
{Java=1, the=3, language=6, programming=5, best=4, is=2}

Example 2

Test it Now

Output:

null
null
null
null
[1, 3, 2, 4]



Help Others, Please Share

facebook twitter pinterest