Suppose a class exists with all its constructors declared private.
For instance:.
public class This { private This () { } public someMethod( ){
From what I know, creating all private constructors is similar to declaring the "This" class as final - so that it cannot be extended.
However, the Eclipse messages that I receive give me the impression that this is possible - you can extend the extension of the all-constructors-private class. Take a look at this:
When I try to extend this class with something like
public class That extends This { ... }
Eclipse gives me an error: "The implicit super constructor This () is not displayed for the default constructor. An explicit constructor must be defined.
When I define my own constructor:
public class That extends This { That () {..} ... }
this time I get: βThe implicit super constructor This () is not displayed for the default constructor. Must explicitly reference another constructor.
Is there a way around this - extending a class from which all constructors are private?
if so, how?
If not, what's the difference between stopping the class from expanding by i.) Making its constructors private, and ii.) Defining it as final ?
Note: I have seen. Can a constructor in Java be private? among some other discussions.
source share