Java specification allows a class with default access to have its constructor public access, what is the purpose of it, since it cannot be referenced outside its package?
I wanted to make this a comment, but since no code tags are allowed in comments....
In regards to your comment on CristopheDs answer:
package bob;
class MySuperHiddenClass {
public MySuperHiddenClass() {
System.out.println("bob");
}
}
And
package bob;
public class MyPublicClass extends MySuperHiddenClass {
}
No constructor was declared in MyPublicClass, but you can still call new MyPublicClass from any package.
If you are asking for why you can have public constructors: it's because you can for example call them explicitely (or implicitely) when you extend a base class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With