Using final to Prevent Overriding : Final Class « Class Definition « Java Tutorial






class A {
  final void meth() {
    System.out.println("This is a final method.");
  }
}
   
class B extends A {
  void meth() { // ERROR! Can't override.
    System.out.println("Illegal!");
  }
}








5.26.Final Class
5.26.1.Final Classes
5.26.2.Using final to Prevent Overriding