IdentityHashMap size Example

IdentityHashMap class size example. This example shows you how to use size method.


IdentityHashMap class size example.public int size() Returns the number of key-value mappings in this identity hash map.

Here is the code

/**
 * @ # Size.java
 * A class repersenting use to size method 
 * of IdentityHashMap class in java.util package
 * version 26 May 2008
 * author Rose India 
 */
import java.util.*;

public class Size {

    public static void main(String args[]) {
        IdentityHashMap map = new IdentityHashMap();

        //Add the mapping into the map 
        map.put(1"A");
        map.put(2"A");
        map.put(3"B");
        System.out.println("map = " + map + "\n" +
                "Size of the map = " + map.size());

    }
}

Output
map = {3=B, 2=A, 1=A}
Size of the map = 3

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US