Using final to Prevent Inheritance
Many times you will need to avoid a class from being inherited. To do this, process the class declaration along with final. Declaring a class a final implicitly declares all of its methods a final, too. As you may expect, it is illegal to declare a class as both abstract and final because an abstract class is incomplete through itself and relies upon its subclasses to gives complete implementations.
Here is an instance of a final class:
final class A {
// ...
}
// The following class is illegal.
class B extends A { // ERROR! Can't subclass A
// ...
}
As comments imply, this is illegal for B to inherit A because A is declared as final.