首页 > 其他 > 详细

面向对象(模板方法模式)

时间:2014-07-22 00:24:03      阅读:300      评论:0      收藏:0      [点我收藏+]

bubuko.com,布布扣

/**
* Created by rabbit on 2014-07-21.博客园.刘朋程
*/
//Created by rabbit on 2014-07-21.博客园.刘朋程
abstract class GetTime
{
    public void getTime()
        {
        long start = System.currentTimeMillis();
            record();
        long stop = System.currentTimeMillis();
        System.out.println("毫秒:"+(stop-start));
        }
    public abstract void record();
}
//Created by rabbit on 2014-07-21.博客园.刘朋程
class SubTime extends GetTime //继承父类将抽象方法record进行复写,定义程序
{
    public void record()
    {
        for (int x=1;x<1000;x++)
        {
              System.out.println("*");
        }
    }
}
//Created by rabbit on 2014-07-21.博客园.刘朋程
public class TemplateDemo {
    public static void main(String [] args)
    {
        SubTime gt = new SubTime();
        gt.getTime();
    }

}

面向对象(模板方法模式),布布扣,bubuko.com

面向对象(模板方法模式)

原文:http://www.cnblogs.com/liupengcheng/p/3858284.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!