The code snippet below show you how to obtain the PI value in Java. We use the `Math.PI`

static field to get the value of PI.

package com.javacoderanch.example.math;
public class GetPIExample {
public static void main(String[] args) {
//
// The pi value represented by Math.PI
//
System.out.println("PI = " + Math.PI);
//
// Using the Math.PI to calculate area of a circle.
//
double radius = 8;
double circleArea = Math.PI * Math.pow(radius, 2);
System.out.println("Circle Area = " + circleArea);
}
}