.
, doSomething.
-, , , . , , - -, , , doSomething. , , . , doSomething , - no operation. , , , .
You should also ask yourself if you really need a base class for an abstract class. Perhaps all you need is an interface. There may be a better approach, but based on the information I have and what I suggested, then it seems to be all right.
public abstract class Base
{
public abstract void doSomething();
public void someOtherMethod()
{
}
}
public class SubTypeWhichCanDoSomething extends Base
{
@Override
public void doSomething()
{
}
}
public class DoesNothing extends Base
{
@Override
public void doSomething()
{
return;
}
}
for(Base base : bases)
{
base.doSomething();
}
Marek source
share