I am trying trying to import java.lang.Math in Java on Eclipse and am getting the error in the title. Here is the beginning of my code:
import java.lang.Math;
package test1;
This error is popping up under "package test1;"
The package
statement must be first in the file, before anything, even imports:
package hw1;
import java.lang.Math;
Plus, you don't need to import java.lang.Math
, or anything in java.lang
for that matter.
The JLS, Chapter 7 says:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With