A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© wuyuwen 中级黑马   /  2014-12-19 20:19  /  606 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

package text;

class TemplateDemo{
        public static void main(String[] args){
                SubTime gt=new SubTime();
                gt.runcode();
        }
}
public abstract class GetTime {
public GetTime(){
        long start=System.currentTimeMillis();
        runcode();
        long end=System.currentTimeMillis();
        System.out.print("毫秒="+(end-start));
}
abstract void runcode();
}
class SubTime extends GetTime
{
        void runcode(){
                for(int x=0;x<1000;x++);
                {
                        System.out.print("x");
                }
        }
}

2 个回复

倒序浏览
x毫秒=4x
回复 使用道具 举报
不知道你是怎么做的?我的运行出来就是
x毫秒=4x
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马