Final keyword

  final keyword in Java

Anything declared as final prevents its contents from being modified.

A member, class , method can be declared as final.

1. final variable

1.The variable which is declared with final keyword is constant.
2.A final variable must be initialized at the time of declaration or before its use.

2. final function

1.The function which is declared with final keyword is never overridden because final prevents method overriding.

3. final class

A class declared as final cannot be extended.

Post a Comment

0 Comments