Java IdentityHashMap clear() method

The clear() method of the Java IdentityHashMap class is used to remove all the key-value pairs from the calling IdentityHashMap. The IdentityHashMap will become empty after calling this method.

Syntax

Example 1

Output:

is->2
best->4
Java->1
the->3
language->6
programming->5
true

Example 2

Output:

false
true