/*
定义功能,获取程序运行的时间。
在指定程序运行前记录一个时间。
在运行后记录一个时间,在相减 就哦了。
模版方法设计模式:
解决问题:当功能中一部分确定,一部分不确定,确定的部分还在使用不确定的部分,
就将不确定的部分暴露出去由子类去实现。
*/
abstract class GetTime
{
public final  void getTime()
{
long start = System.currentTimeMillis();
code();
long end = System.currentTimeMillis();
System.out.println("毫秒是:"+(end-start));
}
public abstract void code();
}
class Sub extends GetTime
{
public void code()
{
for(int x=0; x<10000; x++)
{
System.out.print("a");
}
}
}
class  TemplateDemo
{
public static void main(String[] args) 
{
//GetTime gt = new GetTime();
//gt.getTime();
Sub s = new Sub();
s.getTime();
}
}