Can anyone explain what is Hashcode and why it is important?
The "what" part of your question is a mathematical concept. When applied to Java(public int hashCode() method of Object class), it represents an integer value which is a transform of the hexadecimal memory representation of the object on the heap. To understand its importance, first you need to understand about data structures in Java, especially those which use hashing algorithms to store elements in them(like HashMap, HashSet, Hashtable etc..). Read about collection framework first. Then I would be in a better position to explain to you the "why is it important" part of your question.
Mansukhdeep Thind wrote:When applied to Java(public int hashCode() method of Object class), it represents an integer value which is a transform of the hexadecimal memory representation of the object on the heap.
That statement is somewhere between incorrect and meaningless.
In fact it's not specified how Object will compute its hashCode, although it's "typically implemented by converting the internal address of the object into an integer". Note that "internal address" doesn't really have any relation to "hexadecimal memory representation," whatever that latter is supposed to mean.
Mansukhdeep Thind wrote:So how exactly does the JVM calculate the hashCode() for an Object? How is it implemented?
We don't know and we don't care. It's not specified.
And what does internal address mean?
It refers to the actual memory address in the computer where the JVM sees the object as being stored. Note that because of virtual memory, that may not be the same as the physical RAM address of the object.
It would be some bit pattern. Correct?
Of course it would. What data is stored in a computer that is NOT a bit pattern? (Hint: The answer is, "None.")