"final" Variables in Java

Mannan Ul Haq
0

`final` Variables:

  • A `final` variable is a read-only variable whose value cannot be changed once it is assigned.
  • It is declared using the `final` keyword.
  • `final` variables must be initialized at the time of declaration.

Here's an example:


final int MAX_VALUE = 100;


In this example, `MAX_VALUE` is a `final` variable with a value of 100. Its value cannot be modified throughout the program.


Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Check Now
Accept !