MyClass mcc1d = new MyClass(18, "hello");
System.out.println(mcc1a);
Why is the following the output of the code above?
MyClass@23fc625e
MyClass mcc1d = new MyClass(18, "hello");
System.out.println(mcc1a);
Why is the following the output of the code above?
MyClass@23fc625e
This is because in Java, System.out.println()
applied on an object calls .toString()
. The default of the .toString()
-method returns the class name followed by @
followed by the hash representation of the object.