类中的tostring方法是自动执行的吗?
dog a = new dog()
此时输出a,是内存地址可以理解
但是代码不变 只在类中加tostring方法的话 为什么这个方法就执行了?
我的理解为
先String b = a.tostring();
在输出。
dog a = new dog()
此时输出a,是内存地址可以理解
但是代码不变 只在类中加tostring方法的话 为什么这个方法就执行了?
我的理解为
先String b = a.tostring();
在输出。
2018-08-03
举报