3:53 pm - Monday March 24, 4921

HashMap Example program for equals(Object o)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*HashMap Example program for equals(Object o)
* @author   candidjava.com
* @description: this program check the 2 hashmap's object value are same
*/
import java.util.IdentityHashMap;

public class EqualsOf {
public static void main(String args[]) {
// create 2 identity hash maps
IdentityHashMap ihmap1 = new IdentityHashMap();
IdentityHashMap ihmap2 = new IdentityHashMap();

// populate 2 maps
ihmap1.put(1, "java");
ihmap1.put(2, "util");
ihmap1.put(3, "package");

ihmap2.put(1, "java");
ihmap2.put(2, "awt");
ihmap2.put(3, "package");

// compare 2 maps
boolean isequal=ihmap1.equals(ihmap2);

System.out.println("Is two maps equal: " + isequal);
}
}

OUTPUT:

Is two maps equal:false

Filed in: Z-A All Java Codes

Comments are closed.