看板 java 關於我們 聯絡資訊
※ 引述《walm20 (我要買車啦)》之銘言: : interface Move : { : public int walk=1; : public int run=2; : public int jump=3; : public void moving(int move); : } : interface Hole : { : public void holing(); : } : class Mouse implements Move,Hole : { : public void moving(int move) : { : switch(move) : { : case walk: : break; : case run: : break; : case jump: : break; : } : } : public void holing() : { : } : } : 想請問雖然interface 裡面的變數 : 可以拿來當switch case的判斷 : 是不是因為它是自動設定interface裡面的attribute為const阿? 是的 任何定義在interface中的global variable 在編譯時都會被自動補完成 public static final xxx XXXXX; 就算你前面什麼modifier都不加也會被補完 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.228.211.21