public abstract class GetTime {
public final void getTime(){
long start = System.currentTimeMillis();
runMethod();
long end = System.currentTimeMillis();
System.out.println("时间: "+(end-start));
}
public abstract void runMethod();
}
public class SubTime extends GetTime{
public void runMethod(){
int count=0;
for (int i = 0; i < 4000; i++) {
System.out.print(i);
}
}
}
public class Run {
public static void main(String[] args) {
// TODO Auto-generated method stub
SubTime s = new SubTime();
s.getTime();
}
}