Reputation: 3193
I wanted to know if there is possibility to generate constructors
for all subclasses in IntelliJ
.
I mean if i have many subclasses and somewhere in development stage I wanted to add new constructor
, with a flag, for example. Is there a way to generate this constructor
in all subclasses too?
Upvotes: 0
Views: 859
Reputation: 68915
I wanted to know if there is possibility to generate constructors for all
subclasses in IntelliJ?
The answer would be no and one of the reason would because it is design specific.
When you create a subclass and define a non default constructor in it you have the liberty to call any one of the overloaded superclass constructor from it. Which one would be design choice as initialization of superclass variables may depend on it. Never the less call to one of the overloaded super class constructor must be 1st statement of subclass constructor. If you do not provide any, call to default constructor of super class is inserted by default by the JVM. However in that case if your super class does not have default constructor(you have explicitly provided some parameterized constructor) then compiler error will occur.
Upvotes: 1