1 // Final.java -- double dynamic dispatch resolved using "final" methods 2 3 class Base { 4 void method1 () { 5 System.out.println ("Base.method1()"); 6 method2(); 7 } 8 final void method2 () { System.out.println ("Base.method2()"); } 9 } 10 11 class Derived extends Base { 12 void method1 () { 13 System.out.println ("Derived.method1()"); 14 super.method1(); 15 } 16 // inherit "method2", but it can't be changed (overriden) 17 } 18 19 public class FinalDDD { 20 public static void main (String[] args) { 21 new Derived().method1(); 22 new Base().method1(); 23 } 24 }