Recommended Free Tools
Java’s inherited Object.toString() returns a class name, an at sign, and the hexadecimal form of the object’s hashCode(): getClass().getName() + "@" + Integer.toHexString(hashCode()). The suffix is a hash-code rendering, not a memory address. For a representation based specifically on object identity—even when a class overrides hashCode()—use Objects.toIdentityString(object), available since Java 19.
What does the hexadecimal suffix represent?
When a class inherits Object.toString() without overriding it, Java formats the result as fully.qualified.ClassName@hexDigits. Oracle’s Java SE 21 Object documentation specifies the expression as getClass().getName() + '@' + Integer.toHexString(hashCode()).
The suffix is the hexadecimal rendering of the value returned by hashCode(). It is not specified as a memory address or pointer, so it should not be used to infer where an object resides in memory.
How Java formats the hexadecimal value
Integer.toHexString(int) converts an int to an unsigned base-16 string. It uses lowercase digits (0–9 and a–f), does not add leading zeroes, and can return up to eight hexadecimal digits. A negative int is displayed as its unsigned 32-bit hexadecimal representation, without a minus sign. Oracle documents these details in the Java SE 21 Integer API. To display uppercase digits, call toUpperCase() on the returned string.
Free tools Windows power users keep installed
One-click scans. No signup required.
Why can overriding hashCode() change the suffix?
The inherited Object.toString() expression calls hashCode(). If a class overrides that method, the inherited string uses the override’s result, so its suffix may differ from the identity-based hash code. An application-defined toString() can also return any format its author chooses; the ClassName@hex pattern applies to the inherited implementation, not every Java object.
How to format an identity hash code
Call System.identityHashCode(object) to get a hash code with identity semantics, regardless of whether the object’s class overrides hashCode(). Convert that integer with Integer.toHexString():
Rank #2
String hex = Integer.toHexString(System.identityHashCode(object));
This produces only the hexadecimal suffix. To reproduce the class-name-and-suffix shape without relying on overridable hashCode(), Java 19 and later provide Objects.toIdentityString(object). Oracle’s Java SE 26 Objects documentation specifies its result as o.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(o)). The method throws NullPointerException if its argument is null.
Choosing the appropriate expression
| Expression | Hash source | What it is for |
|---|---|---|
object.toString() when inherited from Object |
Calls hashCode(), which may be overridden |
The default object string representation |
Integer.toHexString(System.identityHashCode(object)) |
System.identityHashCode(object) |
The identity-based hexadecimal suffix alone |
Objects.toIdentityString(object) |
System.identityHashCode(object) |
The class-name-and-hex format, without calling overridable methods |
Example
This example prints the inherited string, an identity-based string, and the identity hash code as hexadecimal:
import java.util.Objects;
class Demo {
public static void main(String[] args) {
Object object = new Object();
System.out.println(object.toString());
System.out.println(Objects.toIdentityString(object));
System.out.println(Integer.toHexString(System.identityHashCode(object)));
}
}
Rank #4
For an ordinary Object, the first two lines follow the same format and use the same identity-based hash behavior. If a class overrides hashCode(), its inherited toString() can have a different suffix; Objects.toIdentityString() remains identity-based.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute

