Changes between Version 4 and Version 5 of waue/2009/0717


Ignore:
Timestamp:
Jul 17, 2009, 1:59:31 PM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2009/0717

    v4 v5  
    4747 * 回到第一個範例,Father whoami = new Son(); 感覺很無聊,怎麼不Father whoami = new Son(); 就好了,還要惡搞Father & Son ,難道只是用來出考題的?
    4848   * 其實如果Father為抽象類別,Son繼承Father並為實做完後的類別,則Son whoami = new Son();當然ok,但若想要僅用Father的參數,只是透過Son以 new出來(Father為抽象類別無法用new),則Father whoami = new Son(); 就很實用了
     49
     50
     51 == 釐清 抽象 與 介面  ==
     52
     53{{{
     54#!java
     55abstract class Demo {
     56abstract void method1();
     57abstract void method2();
     58
     59
     60
     61interface Demo {
     62void method1();
     63void method2();
     64
     65}
     66}}}
     67
     68 * abstract :Demo可以有自己的數據成員,也可以有非abstarct的成員方法,
     69 * interface:Demo只能夠有靜態的不能被修改的數據成員,所有的成員方法都是abstract的。
     70   * interface的成員可看成是 '''static final'''的,不過在interface中一般不定義數據成員
     71 * 從某種意義上說,interface是一種特殊形式的abstract class。