How does intellij calculate 4 digit identifiers of object instances?

When using the Intellij debugger, variables in the area are displayed using a 4-digit identifier, marked in red in the following screenshot. intellij screenshot

This identifier is apparently calculated based on the identifier of the object.

What exact code is used to get a 4-digit number for a given instance of an object?

+5
source share
1 answer

I do not think you should rely on id being computed in any special way. It is internal to IDEA (or JVM), and I don't think it has any meaning other than tracking objects at runtime.

However, I find it helpful to name objects during debugging. I believe that the shortcut is F11 (first click once on the object in the debug window) and just give it a name that makes sense to you during debugging. This object will always hold this name during the current debugging session.

+2
source

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


All Articles