IdentityHashMap clone Example

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


IdentityHashMap class clone example.public Object clone() Returns a shallow copy of this identity hash map: the keys and values themselves are not cloned.

Here is the code

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

public class Clone {

    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);

        //Create clone
        IdentityHashMap map1 = (IdentityHashMapmap.clone();
        System.out.println("Map1 " + map1);
    }
}

Output
Map {2=A, 1=A, 3=B}
Map1 {2=A, 1=A, 3=B}

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

HOME | COPYRIGHT | CONTACT US