+ 1

Can we make a constructor final?

I know constructors cannot be inherited but still is there any possibilities so that a constructor can be made final?

18th Jul 2017, 7:48 PM
Vikram Sah
Vikram Sah - avatar
1 Answer
+ 1
In Java a class constructor is already implicitly final so you cannot make it final. The constructor is not inherited when a class is extended therefore it cannot be overridden. Likewise, you can't make a constructor static or abstract. What are you trying to accomplish by making a constructor final?
18th Jul 2017, 8:17 PM
ChaoticDawg
ChaoticDawg - avatar