Print Constant Value

This program prints the value of a constant using the final keyword.

Problem Statement

Write a Java program that declares a constant and prints its value.

Source Code

1 public class PrintConstant {
2 public static void main(String[] args) {
3 final double PI = 3.14159;
4 System.out.println("Constant PI = " + PI + " - Eduinq");
5 }
6 }

Program Output

Constant PI = 3.14159 - Eduinq

Explanation

final double PI = 3.14159; Declares a constant. Prints the constant value. Conclusion: Shows how to declare and print constants using final.

Quick Links to Explore