Each object has an address hash value in memory, which is in hexadecimal.
Call the hashCode() method of the Object object to return the hash value of this object
Call Integer.toHexString() method to convert hexadecimal
Call the toString() method of the Object object to get: class name @ hash value
Usually we will rewrite the toString() method because the default is not very meaningful
The implementation principle is the reflection of the class
When we create an object, the xxx.class file will be generated on the hard disk. jdk defines the Class class to describe these class files
Call the getClass() method of the Object object to get the Class object
Call the getName() method of the Class object to get the class name
public class ObjectDemo { /** * @param args */ public static void main(String[] args) { ObjectDemo od=new ObjectDemo(); System.out.println(od.toString());//Output ObjectDemo@26f04d94 System.out.println(Integer.toHexString(od.hashCode()));//Output 26f04d94 //Reflect Class c=od.getClass(); System.out.println(c.getName()+"@"+Integer.toHexString(od.hashCode())); }}The above brief discussion of javaSE object-oriented (Object class toString) is all the content I share with you. I hope it can give you a reference and I hope you can support Wulin.com more.