Re: [問題] interface裡的attribute const?
※ 引述《walm20 (我要買車啦)》之銘言:
: ※ 引述《DavyBlue (ArssertionError)》之銘言:
: : 在interface中
: : 所有method都是抽象方法
: : public abstract
: : 無論有無宣告 編譯時都會自動補上
: : 所有類別屬性 都是常數
: : public static final
: : 無論有無宣告 編譯時都會自動補上
: : 以上
: 在問一個問題
: 課本寫說
: interface and abstract class不行建立參考
: 可是後面程式範例
: 有建立interface參考到一個繼承這interface的物件(implement這interface的 class)
: 先謝謝大家摟
問題點在於,你了解什麼叫作「建立參考」嗎?
是意指建立一個新的實體 istance
new Something();
//where Something is not an interface nor an abstract class
還是指某個 member field 的定義
Otherthing otherthing;
//where Otherthing is an interface or an abstract class
或者是指多型 Polymorphism
Otherthing otherthing = new Something();
// where Something is a class that implements Otherthing, and
// Otherthing is an interface
哪一道?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.205.85
討論串 (同標題文章)