Final Keyword in Java

Final Variable:
Final variables can be declared using final keyword.
Once created and initialized, its value can not be changed.


Syntax:
final <datatype> <variable>=<value>;


public class FinalVariable {
 
        public static void main(String[] args) {
              
                final int hoursInDay=24;
               
                //This statement will not compile. Value can't be changed.
                //hoursInDay=12;
               
                System.out.println("Hours in 5 days = " + hoursInDay * 5);
               
        }
}


Output :
Hours in 5 days = 120