[問題] interface裡的attribute const?
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阿?
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.169.113.157
推
04/11 02:00, , 1F
04/11 02:00, 1F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 10 篇):