Constants

Constants in Java

Constants in Java are used when a ‘static‘ value or a permanent value for a variable has to be implemented. Java doesn’t directly support constants. To make any variable a constant, we must use ‘static’ and ‘final’ modifiers in the following manner:

Syntax to assign a constant value in java:

static final datatype identifier_name = constant;

Example:

static final double pi=3.14;

The static modifier causes the variable to be available without an instance of it’s defining class being loaded

The final modifier makes the variable unchangeable

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad