Java How To Import Math
If you are reading this it is because you want to know how to import Math in Java. Fortunately this is probably one of the the single easiest Java related questions that I could possibly answer.
Answer: To import Math in Java just use the following: import static java.lang.Math.*;
Here is an example showing how to do this. It also shows some of the neat things you can do with the Math library. This is also a huge time saver if you need any of these functions.
import static java.lang.Math.*;
class Test1 {
public static void main( String args[] ) {
System.out.println(PI);
System.out.println(E);
System.out.println(abs(-25));
System.out.println(max(15, -25));
System.out.println(min(15, -25));
System.out.println(pow(25, 3));
System.out.println(exp(5));
System.out.println(log10(15));
System.out.println(sqrt(16));
System.out.println(cbrt(64));
}
}