How can I achieve this without the final keyword? What must I change to the constructors?
public final class testName {
testName() {
//do something
}
}
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.
If you make all your Constructors
private, then the class will also no longer be extendable.To see why, check section 3.4.4.1, ‘The default constructor’. By declaring your private default constructor, the last sentence of the paragraph holds:
So effectively by declaring a constructor in the superclass that is not accessible, there is no (other) constructor that your subclass could call and thus Java prevents compilation.