banner
指数爆炸

指数爆炸

我做了对饭 !
github
bilibili

The constructor of the superclass must finish before the constructor of the subclass.

The constructor of the subclass is the first one to be called, but it is the last one to finish.

The call to super() is the first statement of the constructor.




Parent class:
image

Child class:
image

Demo class:
image

Result:
image




The compiler automatically adds super() at the beginning of each constructor.

In fact, the subclass's constructor has a super() added before it.
image

The parent class also has it, but it calls the object class.
image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.