- abstract class GetTime
- {
- public final void getTime1()
- {
- long star = System.currentTimeMillis();
- chengxu();
- long end = System.currentTimeMillis();
- System.out.println("毫秒:" + (end - star));
- }
- public abstract void chengxu();
- }
- class Program extends GetTime
- {
- public void chengxu()
- {
- for (int x = 0; x < 1000; x++)
- {
- System.out.print("x");
- }
- }
- }
- class Game6
- {
- public static void main(String[] args)
- {
- Program gt = new Program();
- //gt.chengxu(); //方法调用错误. 这只是打印方法.
- gt.getTime1(); //要时间得调用这个方法, 这是你自己写的.
- }
- }
复制代码 |