黑马程序员技术交流社区

标题: 模板设计模式? [打印本页]

作者: pz_xiaoxie    时间: 2015-9-11 11:10
标题: 模板设计模式?
package test;

import org.omg.IOP.Codec;
import org.w3c.dom.DOMError;

public class Test02 {

        public static void main(String[] args) {
                // TODO 自动生成的方法存根
             Demo dm=new Demo();
             dm.getTime();
         }

}
abstract class GetTime{
         public final  void  getTime(){
                 long start=System.currentTimeMillis();
                   code();
                 long end=System.currentTimeMillis();
                 System.out.println("程序运行的时间是:"+(end-start));
                 
         }
         public  void code(){};
}

class Demo extends Test02{
     public void getTime(){
     }
         public void code() {
                for(int x=0;x<10000;x++){
                        System.out.println("x:"+x);
                }
        }
         
}
作者: pz_xiaoxie    时间: 2015-9-11 11:11
搞不定,没输出,大神们求帮忙
作者: pz_xiaoxie    时间: 2015-9-11 11:26
搞不定,没输出,大神们求帮忙
作者: hhqnmlgb    时间: 2015-9-11 15:30
你继承了Test02,应该继承GetTime
作者: 插兜    时间: 2015-9-11 16:27
我有点看不懂,我是新手
作者: Wqi    时间: 2015-9-11 21:09
继承错了~~~




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2