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






Java Final variable: Once created and initialized, its value can not be changed

 


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

   
  








Related examples in the same category

1.Blank final fields
2.Experiment with final args to functionsExperiment with final args to functions
3.Using final with method arguments
4.The effect of final on fieldsThe effect of final on fields
5.Making an entire class final