Think in java里面有这样一句话:构造函数没有返回值,这一点同void型的方法有着本质的区别,void型的方法什么都不返回,但这是你决定的,你也可以让它返回些什么.而构造函数则什么都不返回,而且你别无选择.
那请问:我能让void型的方法返回些什么呢???(它说是有你决定的),请大家为举个例子,谢谢
...全文
158719打赏收藏
急,java构造函数没有返回值与void型方法的本质区别(求助)
Think in java里面有这样一句话:构造函数没有返回值,这一点同void型的方法有着本质的区别,void型的方法什么都不返回,但这是你决定的,你也可以让它返回些什么.而构造函数则什么都不返回,而且你别无选择. 那请问:我能让void型的方法返回些什么呢???(它说是有你决定的),请大家为举个例子,谢谢
The constructor is an unusual type of method because it has no return value. This is distinctly different from a void return value, i……
[/Quote]而且如果如这里说的改变返回类型,那也就不是void方法了,这里的“in which the method returns nothing but you still have the option to make it return something else”。那这里的it也就无从解释了(它不是void方法吗?)。我觉得这里的意思不是改变返回类型,而是void方法确实会返回一些什么东西,比如方法控制权。
The constructor is an unusual type of method because it has no return value. This is distinctly different from a void return value, i……
[/Quote]“这完全不同于一个返回值为void类型的方法,这个方法没有返回任何东西,但是你仍然有这样的选择,使得它返回别的什么东西。”而不是如上面解释的改变它的返回类型,至少英文里没有说这句话。我感觉不是翻译的问题,如果是我我也这样翻译,因为译者不能凭空区猜测作者的意图。译者的英文水平不会比我们的差。只是大师在这里也没有说清楚啊(写出一本旷世之作也是辛苦的事,难免会有瑕疵)。
The constructor is an unusual type of method because it has no return value. This is distinctly different from a void return value, i……
[/Quote]这都找到了啊 给力呵呵
The constructor is an unusual type of method because it has no return value. This is distinctly different from a void return value, in which the method returns nothing but you still have the option to make it return something else. Constructors return nothing and you don’t have an option.