java - Call parent method instead of the overriden one -


i have class c1:

public class c1 {      public void method() {       //do     }      protected void anothermethod() {       if (something) {           method();            /*here, want call method c1.method,             * c2.method called            */       }     }  } 

and class c2 extends , overrides method:

public class c2 extends c1 {      @override     public void method() {         if (something) {             anothermethod();         } else {             super.method();         }     }  } 

my problem described in code comment. can't run parent method in parent class. reason?

annoyingly, can't (setting aside reflective hacks).

but on lines

public class c1 {     public final void _method() /*rename taste*/{     }      public void method(){         _method();     } } 

and override method in derived class. if require base class method, call _method(). think that's nearest writing c1::method() permissible in c++.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -