java.util.IdentityHashMap.values() Method


Advertisements


Description

The values() method is used to get a collection view of the values contained in this map.

Declaration

Following is the declaration for java.util.IdentityHashMap.values() method.

public Collection<V> values()

Parameters

NA

Return Value

The method call returns a collection view of the values contained in this map.

Exception

NA

Example

The following example shows the usage of java.util.IdentityHashMap.values()

Live Demo
package com.tutorialspoint;

import java.util.*;

public class IdentityHashMapDemo {
   public static void main(String args[]) {

      // create identity hash 
      IdentityHashMap ihmap = new IdentityHashMap();

      // populate the ihmap
      ihmap.put(1, "java");
      ihmap.put(2, "util");
      ihmap.put(3, "package");      

      System.out.println("Map values: " + ihmap);
      System.out.println("Collection view of the map: " + ihmap.values());
   }    
}

Let us compile and run the above program, this will produce the following result.

Map values: {2=util, 3=package, 1=java}
Collection view of the map: [util, package, java]

java_util_identityhashmap.htm

Advertisements