本帖最后由 彭璞 于 2012-11-28 15:54 编辑
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<4000;x++){
System.out.print(" "+x);
}
}
}
public class Demo{
public static void main(String[] args){
SubTime gt = new SubTime();
gt.getTime();
}
} |