模板方法模式

名字就说明了意思,代码示例如下

abstract class GetTime{

  public final void getTime(){

    long startTime = System.getCurrentMillis();

    runcode();

    long endTime = System.getCurrentMillis();

    System.out.println(endTime-stratTime);

  }

  public abstract void runcode();

}

 

class SubTime extends GetTime{

  public void runcode(){

    ……

  }

}

posted @ 2013-11-19 22:44  剑握在手  阅读(119)  评论(0编辑  收藏  举报
返回顶部↑