January 2018
Intermediate to advanced
115 pages
1h 37m
English
A variable in Java can be made into a constant by adding the final keyword before the data type. This modifier means that the variable can’t be reassigned once it’s been set, and any attempts to do so will result in a compile-time error.
A local constant must always be initialized at the same time as it’s declared. The Java naming convention for constants is to use all uppercase letters and to separate words with underscores:
Class and instance variables can also be declared as final: