zoukankan      html  css  js  c++  java
  • 面向对象(模板方法模式)

    /**
    * 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();
        }

    }

  • 相关阅读:
    CSS3---用户界面
    CSS3---媒体查询与响应式布局
    HDU 5285 wyh2000 and pupil
    POJ 2488 A Knight's Journey
    POJ 1067 取石子游戏
    POJ 2777 Count Color
    POJ 3259 Wormholes
    Project Euler 26 Reciprocal cycles
    POJ 2104 K-th Number
    POJ 1013 Counterfeit Dollar
  • 原文地址:https://www.cnblogs.com/liupengcheng/p/3858284.html
Copyright © 2011-2022 走看看