我正在尝试在 Eclipse 上用 Java 导入 java.lang.Math,但在标题中出现错误。这是我的代码的开头:
import java.lang.Math;
package test1;
此错误在“package test1;”下弹出
最佳答案
package
语句必须在文件中的第一个,在任何内容之前,甚至是导入:
package hw1;
import java.lang.Math;
此外,您不需要为此导入 java.lang.Math
或 java.lang
中的任何内容。
A compilation unit automatically has access to all types declared in its package and also automatically imports all of the public types declared in the predefined package java.lang.
关于java - token "package"上的语法错误,需要导入 (Java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18926806/