本帖最后由 严学韦 于 2012-8-9 12:14 编辑
- abstract class GetTime
- {
- public final void getTime()
- {
- long start = System.currentTimeMillis();
- runcode();
- long end = System.currentTimeMillis();
- System.out.print("毫秒:"+(end-start));
- }
- public abstract void runcode();
- }
- class SubTime extends GetTime
- {
- public void runcode()
- {
- for(int x=0;x<=1000;x++)
- {
- System.out.print(x);
- }
- }
- }
- class TempDemo
- {
- public static void main(String[] args)
- {
- SubTime s = new SubTime();
- s.runcode();
- }
- }
复制代码 为什么运行时间输不出来呢?我的代码跟毕老师的差不多,几乎一样的呀
|
|