In Java, final keyword can be used with variable, method, class
final variable:
final variable:
- we can not change value of final variable once it is initialized
- if final variable not initialized (blank final variable) at the time of declaration, it must be initialized in constructor A static final variable that is not initialized during declaration can only be initialized in static block.
- final methods can not be overridden but methods can be inherited
- final class can not be inherited
- All variables declared in interface are by default final
- constructor can not be declared final
- If method parameters are declared final then the value of these parameters cannot be changed
- Local final variable must be initialized during declaration
Listing the File System Roots
ReplyDeletejava codes