一个小问题
在阅读<Thinking in Java>的过程中,在I/O那章的最后总结时,有这么一句话,不知道什么意思,请大侠们解惑.
With inheritance , you can create new types of input and output objects. And you can even add a simple extensibility to the kinds of objects a stream will accept by redefining the toString() method that's automatically called when you pass an object to a method that's expecting a String( Java's limited "automatic type conversion").
侯杰的翻译为:
通过继承,你可以产生新类型的input 和 output对象. 你甚至可以重新定义toString(),为这些"可被stream接受的对象类型"进行简单的扩充.当你将某个对象传入某个"预期收到String的函数时,便会自动调用该对象的toString(),这是JAVA提供的有限度自动型别转换功能.
我知道在象"+"之类的操作符时,对象的toString()方法是能自动调用,但这儿是什么意思呢? 请大侠说详细一点,最好有个小例子让兄弟看看. 谢谢.