Object.toString() does not return the hashcode value of the object in java but instead give some string

Vishal Sharma :

I have written the following code:-

Test ob = new Test();
System.out.println(ob.toString());
System.out.println(ob.hashCode());

and the output is

Test@15db9742
366712642

i understand that the second value is the hashcode of the object and it is an integer value but i am not able to understand what is the first value. If it is the hashcode of the object then how can it be string and not integer

RAJO SINGH :

It represents classname@HashCode_in_Hexadeciaml_form. So, the string which you are seeing is actually the hexadecimal form of the integer hashcode

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=71655&siteId=1