java - Why can I inherit final method from inner class? -
i discovered following code compiles:
class ideone { public static void main (string[] args){ new ideone().m(); } final private void m(){ system.out.println("private final method"); } class extends ideone{ public void method(string [] args){ m(); } } } and executes.
i wondering this.
can explain why java designers(founders) made works?
a final method can inherited sub class regardless sub class outside parent class or inside parent class. cannot override final method in subclass. if final method private cannot inherit in subclass unless subclass inside parent class (like in example).
Comments
Post a Comment