How to get instance number

Is there a way to get the instance number or id, I mean what you can see in the eclipse Debug> Variables window after the class name in the value column.

thank

+3
source share
4 answers

See System.identityHashCode, which returns the number that will be returned if Object.hashCodeit was not redefined on the object. This is not an ideal proxy for identification, since several objects can have the same identifier hash code, but it is quite useful for debugging.

+5
source

By default, the debugger displays the result of the method toString()with the hash code of the object. So you can see the value by executing the method hashCode().

+1
source

, toString().:

return getClass().getName() + "@" + Integer.toHexString(hashCode());
0

, , , . , , . , ( AFAIK). , . , ( ), . .

0

Source: https://habr.com/ru/post/1776959/


All Articles