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.)

Answer from T.J. Crowder on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api
Math (Java Platform SE 8 )
October 20, 2025 - JavaScript is disabled on your browser · Frame Alert · This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version
Discussions

[Java] The import java.util.Math cannot be resolved
it is java.lang.Math More on reddit.com
🌐 r/learnprogramming
9
5
February 13, 2014
How do I use/import the Apache Commons Math Java library?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
4
1
January 19, 2025
How come I didn't need to import java.lang.Math for my code?

java.lang is always imported by default for Java.

More on reddit.com
🌐 r/learnjava
8
2
January 24, 2015
In Java, you cannot import single methods from a class, so how would I do it in my language?
It's always legal to use the fullly qualified name of something instead of importing it in Java source code, like java.lang.System.out.println(libraries.standard.READ_LINE). JVM bytecode also does not have an "import" concept and always refers to things by their fully qualified names. If you'd like to compile to Java source code, you could first compile to an intermediate Java abstract syntax tree that always refers to things with their fully qualified names, then as one of the last operations iterate over the tree, hoisting as many names into import statements as you can. (Sortof the reverse operation of "name resolution" which is one of the first things a compiler does.) So basically this is a code formatting question. Note that Java source does not allow importing two things with the same name, so in some cases you won't be able to hoist all the imports. That's ok. More on reddit.com
🌐 r/ProgrammingLanguages
25
6
March 9, 2024
🌐
W3Schools
w3schools.com › java › java_math.asp
Java Math
assert abstract boolean break byte case catch char class continue default do double else enum exports extends final finally float for if implements import instanceof int interface long module native new package private protected public return requires short static super switch synchronized this throw throws transient try var void volatile while Java String Methods
🌐
JanBask Training
janbasktraining.com › community › java › should-i-import-a-math-library-and-if-so-how
Should I import a math library, and if so how? | JanBask Training Community
August 6, 2025 - The math module provides functions for square roots, trigonometry, logarithms, constants like π (pi) and e, and much more. ... Once imported, you can access its functions using the dot notation.
🌐
Emory
cs.emory.edu › ~cheung › Courses › 170 › Syllabus › 04 › java-lib.html
Importing methods in the Java library
import java.lang.Math in our program. Summary: importing methods in the Java library ·
Find elsewhere
🌐
Quora
quora.com › How-do-I-import-a-math-class-in-Java
How to import a math class in Java - Quora
java.math.BigInteger and BigDecimal: require explicit import (they are in java.math).
🌐
Baeldung
baeldung.com › home › java › java numbers › a guide to the java math class
A Guide to the Java Math Class | Baeldung
January 8, 2024 - In this tutorial, we’re going to describe the Math class that provides helpful static methods for performing numeric operations such as exponential, logarithm, etc.
🌐
Linux Hint
linuxhint.com › import-math-in-java
How to Import Math in Java? – Linux Hint
To import Math in Java, use “java.lang” package or import Math class using “java.lang.Math.*” It will access all the methods and variables of Math class.
🌐
Sololearn
sololearn.com › en › Discuss › 2816992 › how-can-i-import-javalangmaths-to-use-exponents-mathpow
How can I import java.lang.maths to use exponents? (Math.pow) | Sololearn: Learn to code for FREE!
June 20, 2021 - Katharina Hohenfels round, pow, ceil are methods of Math class. As you have already used Math.round() without importing so you can also use Math.pow() without importing. java.lang.*; is default imported package in Java. Math is a class so it should be java.lang.Math not Java.lang.math ·
🌐
Reddit
reddit.com › r/learnprogramming › [java] the import java.util.math cannot be resolved
r/learnprogramming on Reddit: [Java] The import java.util.Math cannot be resolved
February 13, 2014 -

I'm writing a program to calculate the wind chill based on a temperature and wind speed entered by the user. The formula to calculate wind chill is

Wind Chill = 35.74 + 0.6215T - 35.75V0.16 + 0.4275TV0.16

My current code is

import java.util.Scanner;
import java.util.Math;
public class WindChill {

public static void main(String[] args) {
	
	//Declare variables

	double windChill;
	double temperature;
	int    windSpeed;

//Ask the user for temperature and wind speed

System.out.print("Enter the temperature (Fahrenheit):  ");
	Scanner input = new Scanner (System.in);
	temperature = input.nextDouble();

System.out.print("Enter the wind speed(mph):  ");
	windSpeed = input.nextInt();

	
//Display the wind chill value

windChill = (35.74+(0.6215*temperature)) - (Math.pow(35.75*windSpeed,0.16)) + (Math.pow(0.4275*temperature*windSpeed,0.16));	
System.out.print("The wind chill index is " + windChill);
}

}

I get an error in the IDE on line 2 that says "the import java.util.Math could not be resolved". Also, when I try to run the program, I get the error message

"Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

at WindChill.main(WindChill.java:6)

I checked my installed JREs and I am using JRE7. Can anybody tell me what is wrong?

🌐
Jenkov
jenkov.com › tutorials › java › math-operators-and-math-class.html
Java Math Operators and Math Class
This Java math tutorial explains both the basic Java math operators as well as the more advanced Java Math class.
🌐
CodeGym
codegym.cc › java blog › java math › math pow() method in java
Math.pow() Method in Java
December 5, 2024 - Therefore, instead of writing a power function from scratch, we can take advantage of this library that is included in the Java Lang package. Math pow can be found in the java.lang package as a method of the Math library. It is used to calculate the power of numbers, both integers as well as doubles.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-math-class
Java Math Class - GeeksforGeeks
July 23, 2025 - Let us check the method provided in the Math class. ... // Java program to demonstrate the // Use of Math Class public class MathLibraryExample { public static void main(String[] args) { int i = 7; int j = -9; double x = 72.3; double y = 0.34; System.out.println("i is " + i); System.out.println("j is " + j); // The absolute value of a number is equal to the // number if the number is positive or zero and // equal to the negative of the number if the number // is negative.
🌐
GeeksforGeeks
geeksforgeeks.org › java › math-pow-method-in-java-with-example
Math pow() Method in Java with Example - GeeksforGeeks
March 28, 2025 - // importing java.lang package import java.lang.Math; public class GFG { public static void main(String[] args) { double nan = Double.NaN; double result; // Here second argument is NaN, // output will be NaN result = Math.pow(2, nan); ...
🌐
DEV Community
dev.to › mohamad_mhana › mastering-the-math-class-in-java-5ad4
🧮 Mastering the Math Class in Java - DEV Community
October 3, 2025 - The Math class in Java is a utility class that provides a rich set of static methods for performing...
🌐
Coderanch
coderanch.com › t › 629237 › java › java-lang-Math-methods-import
Use java.lang.Math methods without import in IDE [Solved] (Beginning Java forum at Coderanch)
February 22, 2014 - programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums · this forum made possible by our volunteer staff, including ... ... I am able to use a Math method without importing the java.lang.Math.
🌐
TutorialsPoint
tutorialspoint.com › static-import-the-math-class-methods-in-java
Static import the Math Class Methods in Java
July 30, 2019 - import static java.lang.Math.sqrt; public class Demo { public static void main(String[] arg) { double num = 36.0; System.out.println("The number is: " + num); System.out.println("The square root of the above number is: " + sqrt(num)); } }
🌐
Medium
medium.com › @toimrank › java-math-class-6ed5e23f2db0
Java Math Class. Java.lang.Math package in java provides… | by Imran Khan | Medium
September 21, 2022 - Java Math Class Java.lang.Math package in java provides Math class. Math class provides us some of the predefined method such as min, max, sqrt etc. Below are the examples of some of the methods from …