Methods, classes, and variables can be defined as final.
Let’s look at what it means in each scenario
You cannot override final methods in subclasses
Private methods are implicitly final
Static methods are implicitly final
The value of final variable will remain constant
You cannot change the value of final variables
You should immediately assign a value to final variables
Different types of final variables
Final parameter
Final local variable
Final instance variable
Final static variable
An uninitialized final field of a class must be definitely assigned in every constructor of the class
An uninitialized final static variable must be definitely assigned in a static initializer of the class in which it is declared
You cannot inherit from final classes
No class can extend final classes
Final data:
Constant
Local variables or instance variables
Primitives —> constant values
Objects —> constant references
Final Methods
No override