“The constructor is not visible” error

≡放荡痞女 提交于 2019-11-29 15:00:07

No access modifier for your constructor makes it package private. Assuming that First and Second are in the same package, you can call Second's constructors from first. Another class from another package, however, cannot access any of the constructors.

Your class must be in 2 packages. If you don't mention any explicit access modifier Java will consider them as default access modifier. Then you can only access them through the same package only.

Access Modifiers (From least access to highest access)

  1. private - Only within same class
  2. default - Only within same package
  3. protected - same package + children classes in other packages
  4. public - From anywhere
Suresh Atta

Since you are not mentined any modifier the access modifier is now default, that means it is visible only within its own package

If you try to use it out side the package, you'll face the current error.

Try to read :What is the default access modifier in Java?

If you did'nt get understood what @BackSlash is commenting, check the below link

Problem with : Calling a method from a superclass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!