[英]cannot find symbol java.awt and java.util
i'm using NB.the ide gives error that it cannot find symbol java.awt .我正在使用 NB.the ide 给出错误,它找不到符号 java.awt 。 tried running the same code in eclipse.it also gives same error.
尝试在 eclipse 中运行相同的代码。它也给出了同样的错误。 it gives the error cannot find symbol even on creation of new JFrame.
即使在创建新的 JFrame 时,它也会给出错误找不到符号。
An error:一个错误:
A class named java
obscures the package name java
, see Java Language Specification 6.4.2 :名为
java
的类掩盖了包名java
,请参阅Java 语言规范 6.4.2 :
A simple name may occur in contexts where it may potentially be interpreted as the name of a variable, a type, or a package.
简单名称可能出现在可能被解释为变量、类型或包的名称的上下文中。 In these situations, the rules of §6.5 specify that a variable will be chosen in preference to a type, and that a type will be chosen in preference to a package.
在这些情况下,第 6.5 节的规则指定将优先选择变量而不是类型,并且将优先选择类型而不是包。 Thus, it is may sometimes be impossible to refer to a visible type or package declaration via its simple name.
因此,有时可能无法通过其简单名称来引用可见类型或包声明。 We say that such a declaration is obscured.
我们说这样的声明是模糊的。
That means that within the package that contains the class java
you will not be able to reference to classes from any of the java.*
packages through qualified names.这意味着在包含类
java
的包中,您将无法通过限定名称从任何java.*
包中引用类。
However you could still import the classes you need and reference them by simple names:但是,您仍然可以导入所需的类并通过简单的名称引用它们:
import java.util.logging.Logger;
import java.awt.EventQueue;
// within some method:
Logger.getLogger(....);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.