本帖最后由 彭盼 于 2012-3-2 10:45 编辑
我学到继承相关知识点时,跟随老师写了个小程序:
abstract class GetTime
{
public final void getTime()//严禁复写
{
long start=System.currentTimeMillis();
runcode();
long end=System.currentTimeMillis();
System.out.println("毫秒:"+(end-start));
}
public abstract void runcode();
}
class SubTime extends GetTime
{
public void runcode()
{
for (int x=0;x<6000;x++)
{
System.out.println("x");
}
}
class TemplateDemo
{
public static void main(String[] args)
{
SubTime sub=new SubTime();
sub.getTime();
}
}
结果运行后,程序老是提示到最后一行进行语法分析已到达文件结尾:
[attachimg]885[/attachimg |
|