+ 1

Why constructors in java can't be static? Any explanation please?

4th Feb 2020, 11:59 AM
Hichem GOUIA
Hichem GOUIA - avatar
4 Réponses
+ 3
Adding to what ~ swim ~ has mentioned. A static method is not inherited by the subclass but a constructor at times might require to call the constructor of base class. If it is static then you cannot do that.
4th Feb 2020, 12:37 PM
Avinesh
Avinesh - avatar
+ 2
I think I get it now. Constructors are executed when an OBJECT is created. It is not like a method that you can call.
4th Feb 2020, 12:08 PM
KnuckleBars
KnuckleBars - avatar
4th Feb 2020, 12:01 PM
KnuckleBars
KnuckleBars - avatar