+ 17
Why constructor cannot be final?
please explain clearly and easy to understand your answer..
6 Respostas
+ 16
When you set a method as final it means: "You don't want any class override it." But the constructor (according to the Java Language Specification) can't be overridden, so it is clean.
When you set a method as abstract it means: "The method doesn't have a body and it should be implemented in a child class." But the constructor is called implicitly when the new keyword is used so it can't lack a body.
When you set a method as static it means: "The method belongs to the class, not a particular object." But the constructor is implicitly called to initialize an object, so there is no purpose in having a static constructor.
+ 7
thnks to explan @whbe
+ 1
the easy answer is that you can think or consider about constructor as "special method", it is a java language (rule) that made this method is constructor.
also, because of the constructor can't be overriden.
so, that's useless to make the costructor method is final.
because the (final) keyword uses to prevent the override, and the constructor can't be overriden by defualt.
hopefully it is clear
+ 1
you're welcome my friend sarath
0
...
0
Constructors are not members of a class,so they cannot be inherited by the super class.Again since they cannot be inherited,they cannot be overridden,so it is of no use to declare a constructor as final.Generaly “final” keyword is used in Java for methods which we don’t want to be overridden.
See method overridden here:- http://crbtech.in/Java-Training/method-overloading-overriding-java-2/