final annotation

The final annotation marks a class as not having subclasses.


final class Example() {



Apart from annotation classes, most classes are not typically annotated final. The semantics of the formal, default and actual annotations are intended so that the author of a class or interface decides which members may be refined. It shouldn't be possible for it to be broken by a subclass, because the subclass can only refine those members it is explicitly permitted to refine.

However, the final annotation is occasionally useful to allow the compiler to detect that two types are disjoint.

See also