What is final variable in java?

The variable declare with the final keyword is called as final variable.
A final variable is a variable which can’t be change its value when once it assigned.

class Hello{
            final int size=3;
Note : Here size value can’t be modified.
Final variable is also called as constant. Thus final variable must be initialized.
Final variable can be primitive, reference and instance.


Post a Comment