Constants in Java
Constants in Java : The value that cannot be changed during the execution of programs. Constant is a value that cannot be changed after assigning it. Java does not directly support the constants. To declare any variable as constant, we use static and final modifiers. It is also known as non-access modifiers. Syntax : static final datatype identifier_name=value; Example : static final float Pi=3.142; here static and final are the non-access modifiers. The float is the data type and Pi is the identifier name in which the value 3.142 is assigned. PROGRAM : Write a java program to to Illustrate use of constants in Java. import java.util.*; public class calculate { final static double pi=3.142; float r; calculate() { System.out.println("calculate area of circle:"); } void getdata() { Scanner sc=new Scanner(System.in); System.out.println("Enter the radius of ci...