How can constants be defined in Java?
There are two ways to define constants in Java.
- last
- last
final int MAX_VALUE = 100;
final double PI = 3.1415926;
final String MESSAGE = "Hello, World!";
- list of options or choices
- list of options or choices
enum Color {
RED, GREEN, BLUE;
}
In the example above, Color is an enumeration type that consists of three constant objects: RED, GREEN, and BLUE.