## What is “π” in mathematics?

The ratio of a circle's circumference to its diameter, which equals 22/7 and is represented by a constant value of 3.14159, is called "pi" in mathematics.## What is Math.PI in Java?

Math.PI is a static final double constant in Java, equivalent to in π Mathematics. Provided by java.lang.Math class, Math.PI constant is used to carry out multiple mathematical and scientific calculations like finding the area & circumference of a circle or the surface area and volume of a sphere. In real life, the “pi” quantity has a fundamental position with never-ending uses. Some of them are listed below.- Aerospace designers use pi to compute the area of the body of the aircraft.
- Medical Science benefits from pi by using it to analyze the structure of the eye.
- Biochemists use pi to study the composition of DNA.
- Statisticians use pi to project the population dynamics of the state.
- Pi has a core value in the current Global Positioning System (GPS) we have today.

### Example

If you want to learn how to get and how to use the value of Math.PI in Java let’s have a look at the following executable example.```
public class PiInJava {
public static double circumferenceOfCircle(int radius) {
return Math.PI * (2 * radius);
}
public static double areaOfCircle(int radius) {
return Math.PI * Math.pow(radius, 2);
}
public static double volumeOfSphere(int radius) {
return (4 / 3) * Math.PI * Math.pow(radius, 3);
}
public static double surfaceAreaOfSphere(int radius) {
return 4 * Math.PI * Math.pow(radius, 2);
}
public static void main(String[] args) {
int radius = 5;
System.out.println("Circumference of the Circle = " + circumferenceOfCircle(radius));
System.out.println("Area of the Circle = " + areaOfCircle(radius));
System.out.println("Volume of the Sphere = " + volumeOfSphere(radius));
System.out.println("Surface Area of the Sphere = " + surfaceAreaOfSphere(radius));
}
}
```

#### Output

Circumference of the Circle = 31.41592653589793
Area of the Circle = 78.53981633974483
Volume of the Sphere = 392.6990816987241
Surface Area of the Sphere = 314.1592653589793

GO TO FULL VERSION