publicstaticvoidmain(String[] args) { Demo d = new Demo(); System.out.println(d.getTime()); }
abstractclassGetTime { public final longgetTime() { long start = System.currentTimeMillis(); code(); long end = System.currentTimeMillis(); return end - start; }
publicabstractvoidcode(); }
classDemoextendsGetTime {
@Override publicvoidcode() { int i = 0; while(i < 100000) { System.out.println("x"); i++; } } }