What are final variables?
What are final variables?
Rating:
Variables declared with the keyword final as a modifier are called final variables. They are so called because once initialized a value, their values cannot be modified. Any attempt made to modify the value of a pre-initialized final variable will result in a compile time error.
A final variable is declared as shown below:
where, IAMFINAL is the name of variable whose data type is double. This statement declares the variable IAMFINAL as final and initializes it with the value 0 at the same time. Further attempts to change the value of IAMFINAL will result in a compile time error.
Rating:
Other articles
- What is the Comparable interface?
- Things to practice for Sun test CX310-055.
- Constructors
- What is the XOR operator?
- What is the Pattern class?
