How to define constants in Java
In Java, the final keyword can be used to define constants. Once a constant is assigned a value, that value cannot be changed.
The format for defining a constant is: final data type constant name = value;
Here are some examples of constant definitions:
final int MAX_NUMBER = 100;
final double PI = 3.14159;
final String MESSAGE = "Hello, World!";
Note: According to Java naming conventions, constant names are typically written in uppercase letters with underscores in order to differentiate them from variables.