Why constructors in java can't be static? Any explanation please? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

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

4th Feb 2020, 11:59 AM
Hichem GOUIA
Hichem GOUIA - avatar
3 Answers
+ 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