示例:我如何将进一步的SpecificProcessing 方法设为私有方法?
原因:我希望能够新建一个 B 或 C 类型的对象,并且只有 doStuff() 对程序员可见。同时 B 级和 C 级提供附加功能
abstract class A
{
protected abstract void furtherSpecificProcessing();
//concrete method utilizing abstract method
public void doStuff()
{
//busy code
furtherSpecificProcessing();
//more busy code
}
public class B extends A
{
public void furtherSpecificProcessing
{
//Class B specific processing
}
}
public class C extends A
{
public void furtherSpecificProcessing
{
//Class C specific processing
}
}