The default implementation of hashCode() provided by Object is derived by mapping the memory address of the object to an integer value.
equals() and hashCode(). In general, if you override one of these methods, you must override both, as there are important relationships between them that must be maintained Java object support hashCode() allows for efficient storage and retrieval using hash-based collections. the equals() method must exhibit the following properties:
Symmetry: For two references, a and b, a.equals(b) if and only if b.equals(a)
Reflexivity: For all non-null references, a.equals(a) Transitivity: If a.equals(b) and b.equals(c), then a.equals(c) Consistency with hashCode(): Two equal objects must have the same hashCode() value
Blog provide core concept of Java , J2ee , Struts Framework, Spring, Hibernate, apache ofbiz,Hybris e-commerce suit.Net4.0 framework,Websphere Application Server (WAS), DB2, WSAD and JavaScript. Also covers Tips and Tricks , Codes , Tutorials , Solutions for Developers , latest Interview Questions & Answers
Important point should remember about Object's hashCode and Equal method to Freahser Java developer at time of interview
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.