I know there have been lots of thread about Java inheritance (and i already read it), but they all stand for \"how it is\", and I need knowledge \"how to change it\". So, we hav
Yes, there is a way do to this. You can apply pattern which called "Template method". Here is an example
class Base {
void someMethod() {
int value = getValue();
// calculate something
}
protected abstract int getValue();
}
class Derived extends Base {
int getValue() {
return 5;
}
}
Where getValue()
is your template method and you can insert any logic in your inherited classes implementations.