Should I import a math library, and if so how?
35,625
Solution 1
E
and PI
are not functions, they're static fields (data members). That code will output their values correctly. You don't have to import anything, the Math
class is in the java.lang
package, which is imported by default. (It's the only package imported by default, I believe.)
Solution 2
You don't have to import anything here. The java.lang.Math
class should already be available as java.lang
package is imported by default
Author by
user3314801
Updated on February 24, 2020Comments
-
user3314801 about 4 years
So I want to print out the math functions, "PI" and "E."
Here is how I'm trying to do it:
System.out.println(Math.PI); System.out.println(Math.E);
I think I have to import the math library.