Working in Java.
I have defined several different abstract classes that each has a static method called aCommonMethod. Each one also has a dependent method that itself calls aCommonMethod, as follows:
public abstract class SomeAbstractClass{
public static void aCommonMethod() {
// does something
}
public static void someDependentMethod() {
//some stuff
aCommonMethod()
//some more stuff
}
}
The method someDependentMethod is identical for each of my abstract classes except for what method gets called by invoking aCommonMethod.
What is the idiomatic way, in Java, to implement this? So far I can't find anything that works other than actually copying the aCommonMethod method into each of my abstract classes. Obviously, it would be preferable to write the method just once somewhere and then have my abstract classes inherit it somehow. I cannot find any way to do that in Java.