6

The "@" seems to be everywhere when I debug. They are always preceded by some instance/variable name and followed by a (usually three digits) number. What does it mean? I have an image belowenter image description here

Taken from https://medium.com/@andrey_cheptsov/intellij-idea-pro-tips-6da48acafdb7 .

NewStudent
  • 193
  • 10

2 Answers2

2

@730 means the 730th object created since the application started. It is not the hashcode. Length of this can be more or less than 3 digits.

It's totally depends upon which IDE you are using, may eclipse will give something else instead of @730 and in different format also, so it is the way of intellij to maintaining the debugging.

ajay tomar
  • 384
  • 1
  • 16
  • 1
    In relation to the answer I also found this link enlightening: https://www.javalobby.org/java/forums/t19718.html . – NewStudent May 31 '18 at 13:52
2

This is Intellij debugger's way of displaying a "unique identifier" for an object. It consists of the short classname and a unique number. The unique number seems to be generated using a simple counter, so the "meaning" of 729 in Owner@729 is (presumably) "this is the 729th object that the debugger has allocated an identifier for". However, you probably shouldn't rely on that.

There is no overt relationship between these numbers and Java identity hashcode values, though I expect Intellij maintains a mapping behind the scenes.


The Owner@5f9d02cb in the screenshot is reminiscent of the result of Object::toString ... when it hasn't been overridden. If that it is what it is, then the 5f9d02cb will be the object's identity hashcode.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • is 5f9d02cb the billionth object or some other number created or that only applies to the numerical only strings after the @? – user1689987 Sep 06 '22 at 18:13
  • Like I said. It looks like an identity hashcode. Do some research on how identity hashcodes are generated. (Think about it. Look at the context. Do you *really* think that 1,604,125,387 objects have been created in the OP's toy example? And what would `Pet@729` mean there ... if this was the 1,604,125,387th Pet object?) – Stephen C Sep 07 '22 at 01:23