Dumping a Java object ID to a string

I have wanted to do this in the past, never found the code. I found this handy code here recently. Wanted to save it here. Thanks, dude.

You can also handily convert an integer to a hex string using the Integer class, so you can get the value that would come after the @ in a default toString() implementation by calling this:

Integer.toHexString(System.identityHashCode(object))