I want to know what exactly the output is when I do the following.
class Data {
int a = 5;
}
class Main {
public static void main(String[] args) {
d
When you print an instance of your class, that does not override the toString method, then the toString method of Object class is used. Which prints an output in the form: -
data@1ae73783
The first part of that output shows the type of the object.
And the 2nd part is the hexadecimal representation of the hashCode
of your object.
Here's the source code of Object.toString() method, that you can find in the installation directory of your jdk, under src folder: -
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}