In Java why final keyword is used to make the variable as a constant instead of there is a const keyword available??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 15

In Java why final keyword is used to make the variable as a constant instead of there is a const keyword available???

11th Feb 2018, 9:16 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
4 Answers
+ 4
Because the final is more flexible. Const would mean that the variable is always the same. But each object of a class could have it's own expression of a final value. That's the idea: Once you have made this thing, the value is final.
11th Feb 2018, 10:39 AM
1of3
1of3 - avatar
0
Not override
26th Jan 2019, 1:41 PM
Sachin Kumar
Sachin Kumar - avatar
- 1
It is just the matter of the syntax i.e. in C & C++ we prefer using keyword const and in java final.
3rd Mar 2018, 5:16 AM
Shipra Himanshu
Shipra Himanshu - avatar