There is no such thing as a hash code for a reference variable. A variable is simply a reference, which points to a particular object. That
object can calculate a hash code. I presume you are already familiar with writing hashCode() methods.
You are also confusing overriding and implementing. You said
Nirmal Mukundan wrote:Hello,
I have a Java bean in which I have not overridden the hashcode(). . . . Since I have not implemented the hashcode(), . . .
You have implemented the hashCode method; if you have not overridden it, it is implicitly implemented, but as the version inherited from java.lang.Object. You can’t not implement a hashCode() method, and you can’t un‑implement it.
If you use the same object twice, that will have the same hash code, so you will get the value back. Remember
hashCode() ≡
equals(). If the two objects are equal, they have the same hash code. An object is always equal to itself, so it has the same hash code as itself. So those two uses of the same StudentVO object both have the same hash code. They must have the same hash code; if you haven’t overridden the hashCode() method there is no code to change the hash code.