I have two classes in two different packages. For one class I've defined a constructor without setting access modifier for it. I want to instantiate an object of this class in another package and get the error 'the constructor xxx() is not visible
'.
If I define access modified to public
it is fine. I thought constructors are public by default?
no access specifier != public
No Modifier is package private. check doc
No, they're not. They have package-visibility by default.
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