无法从外部包访问类 [英] Classes cannot be accessed from outside package
问题描述
我有两个包。我想从第一个包导入的类声明为PUBLIC。尽管如此,当我从第二个包中测试一个文件时,它会向我显示如下编译错误:
I have two packages. The class I want to import from the first package is declared as PUBLIC. Despite, when I test a file from the second package it shows me compilation errors like this:
PUBLICclass在mypackage中不公开;无法从外部包访问
PUBLICclass is not public in mypackage; cannot be accessed from outside package
我试图从第一个包中添加一个公共构造函数,但它没有任何差异。
I tried to add a public constructor to the class from the first package, but it doesn't make any difference.
你有什么想法吗?我使用Netbeans 7。
Do you have any ideas? I use Netbeans 7.
第一个包中的类如下所示:
The class from the first package looks like below:
public class PUBLICclass extends AbstractClass { public PUBLICclass() { } }
推荐答案
让我猜测
你的类 PUBLICClass
的初始声明是不公开的,然后你做了它是'公共',你可以尝试清理和重建你的项目吗?
Your initial declaration of class PUBLICClass
was not public, then you made it `Public', can you try to clean and rebuild your project ?
这篇关于无法从外部包访问类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!