摘要:
1 //模板方法模式 2 abstract class time{ 3 public final void getTime() {//不让复写 4 long start = System.currentTimeMillis(); 5 6 runcode(); 7 8 long end = System.currentTimeMillis(); 9 System.out.println("毫秒" + (end - start));10 }11 12 public abstract void runcod... 阅读全文
posted @ 2013-12-21 15:15
天天AC
阅读(139)
评论(0)
推荐(0)
摘要:
具体看代码 1 abstract class student {// 抽象方法放在类中,不能有new创建对象,没意义,必须让子类复写方法,复写后仍未抽象类 2 abstract void study();// 由void study(){}改的 3 // 抽象方法一定有抽象类,必须有关键字修饰 4 // abstract void 5 // study1();//如果有这个,子类必须复写其方法,如果不复写,在子类前必须加abstract,且必须将此方法放在子类中,前要加abstract 6 } 7 8 class BaseStudent extends stu... 阅读全文
posted @ 2013-12-21 14:11
天天AC
阅读(172)
评论(0)
推荐(0)