码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-07-22 00:25:33      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:style   http   width   2014   art   for   

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

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

标签:style   http   width   2014   art   for   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!