[英]Public class inside package can't see public interface?
I have a class:我有一个 class:
package Member;
public class Player implements Character{
...
}
and I have interface that is not inside the package:我有不在 package 内的接口:
public interface Character{
...
}
I think that public intefaces and classes are visible to each other no matter if they are in the same package, so why I can't implement Character in the Player class?我认为公共接口和类是彼此可见的,无论它们是否在同一个 package 中,那么为什么我不能在播放器 class 中实现字符? I have error: Cannot resolve symbol 'Character'
我有错误:无法解析符号“字符”
If the interface (or any other class/enum you use) are in a different package, you need to either fully qualify it:如果接口(或您使用的任何其他类/枚举)位于不同的 package 中,则需要对其进行完全限定:
public class Player implements org.somepackage.Character {
or import it:或导入它:
import org.somepackage.Character;
public class Player implements Character {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.