class is defined as Final Java?

What does it mean if a class is defined as Final?

Final in Java:
A class which is defined as final cannot be extended, which means that it cannot be further subclassed.
Variables defined in an interface are
implicitly final in java.

This is mainly done for security reasons with basic classes like String and Integer.
It also allows the compiler to make some optimizations, and makes thread safety a little easier to achieve. A final method cannot be overridden when its class is inherited.


Post a Comment