Hi all,
I tried to print the value of a reference variable of a class(equals and hashcode not overriden) and i get a value like Classname@hexnumber.
I found out that the hex-number is nothing but the memory address of the object.
BUT,when i override the hashcode and equals,and then i create two equivalent objects,and print the reference variables,I get the same values,because they had same hashCodes,but when i tried to compare them using ==,they were not equal.
So,my question is,even if the reference variables show equal values when printed,why are they not '=='.Do the reference variables store somethong else and display something else?
here is a code
BIG CONFUSION.PLEASE HELP ASAP.
Thanks...
I tried to print the value of a reference variable of a class(equals and hashcode not overriden) and i get a value like Classname@hexnumber.
I found out that the hex-number is nothing but the memory address of the object.
BUT,when i override the hashcode and equals,and then i create two equivalent objects,and print the reference variables,I get the same values,because they had same hashCodes,but when i tried to compare them using ==,they were not equal.
So,my question is,even if the reference variables show equal values when printed,why are they not '=='.Do the reference variables store somethong else and display something else?
here is a code
BIG CONFUSION.PLEASE HELP ASAP.
Thanks...