阅读背景:

为什么必须首先在Java构造函数中委托给不同的构造函数?

来源:互联网 

In a constructor in Java, if you want to call another constructor (or a super constructor), it has to be the first line in the constructor. I assume this is because you shouldn't be allowed to modify any instance variables before the other constructor runs. But why can't you have statements before the constructor delegation, in order to compute the complex value to the other function? I can't think of any good reason, and I have hit some real cases where I have written some ugly code to get around this limitation.In a constructor in Java, if you want to call a




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: