This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When you create instance of any class ( object of any class ) , it live on GCH . So there are lots of object at any time live on GCH So to identify them uniquely JVM gives them a unique key that is known as Hash Code .
Originally posted by rathi ji: ...there are lots of object at any time live on GCH So to identify them uniquely JVM gives them a unique key that is known as Hash Code.
No, hashCode is not a unique key. Per the hashCode contract, equal objects (as defined by the equals method) should return the same hashCode, but there is no requirement that unequal objects return different hashCodes.
See the "hashCode" and "equals" methods in the Java API for Object...
Essentially, hashCode provides a means of "classifying" objects so that they can be "arranged" for faster retrival from a Container like HashSet. For detailed information, see the section, "Hashing and hash codes" in Chapter 11 of Bruce Eckel's Thinking in Java...
rathi, I suggest you take a beginner's course in Java from Sun. SL-110 followed by SL-275 will serve you well. There you'll learn just about everything you're asking questions about and now misinforming people about.