What is a constant in Java?
In Java, constants refer to variables whose values cannot be changed during program execution. Constants can be values of primitive data types (such as integers, floating-point numbers, boolean values, etc.), as well as strings, objects, and so on. Constants in Java are declared using the keyword final, and once assigned a value, they cannot be modified. It is a common convention to name constants using all capital letters, with underscores separating multiple words. For example:
final int MAX_VALUE = 100;
final double PI = 3.14;
final String GREETING = "Hello";
final boolean IS_TRUE = true;