Java Collection Tutorial - Java IdentityHashMap.values()








Syntax

IdentityHashMap.values() has the following syntax.

public Collection <V> values()

Example

In the following code shows how to use IdentityHashMap.values() method.

import java.util.IdentityHashMap;
//from  w w  w  . ja  v  a  2s  .  com
public class Main {
   public static void main(String args[]) {

      IdentityHashMap<Integer,String> ihmap = new IdentityHashMap<Integer,String>();

      ihmap.put(1, "from");
      ihmap.put(2, "java2s.com");
      ihmap.put(3, "tutorial");
      

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

The code above generates the following result.