toString把一个实例对象 转化成一个可打印的字符串toString 的默认返回值:public String toString() {return getClass().getName() + "@" + Integer.toHexString(hashCode());}我们默认的打印的方法就是默认调用 dog 的 toString 方法:System.out.println(dog) java Last Modified: February 5, 2023