Why can’t constructors be final, static, or abstract in Java?
For instance, can you explain to me why this is not valid?
public class K {
abstract public K() {
// ...
}
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you set a method as
finalit means: “I don’t want any class override it.” But according to the Java Language Specification:When you set a method as
abstractit means: “This method doesn’t have a body and it should be implemented in a child class.” But the constructor is called implicitly when thenewkeyword is used so it can’t lack a body.When you set a method as
staticit means: “This 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.