Java Final variable: Once created and initialized, its value can not be changed : final « Class Definition « Java Tutorial






public class Main {

  public static void main(String[] args) {
    final int hoursInDay = 24;
    System.out.println("Hours in a day = " + hoursInDay );
  }
}
//Hours in a day = 24








5.27.final
5.27.1.final Variables
5.27.2.'Blank' final fields
5.27.3.Java Final variable: Once created and initialized, its value can not be changed
5.27.4.Using 'final' with method arguments
5.27.5.The effect of final on fields
5.27.6.You can override a private or private final method
5.27.7.Making an entire class final
5.27.8.Demonstrates how final variables are replaced at compilation time
5.27.9.Demonstration of final class members
5.27.10.Base class for demonstation of final methods
5.27.11.Demonstration of final constants
5.27.12.Demonstration of final variables