看板 java 關於我們 聯絡資訊
各位版友好 enum Choice { EDITPROFILE(0),MAILFOLDER(1),SENDMESSAGE(2),LOGOUT(3); private final int value; private Choice(int value){ this.value=value; } public int getValue(){ return this.value; } }; public class Main{ ... public void onItemClick(int position) { switch(position){ case choice.EDITPROFILE.getValue(): break; case choice.MAILFOLDER.getValue(): break; case choice.SENDMESSAGE.getValue(): break; case choice.LOGOUT.getValue(): break; } } 編譯器告訴我 case 後面必須接 constant,請問我這樣寫法是錯在哪裡呢? 謝謝 -- ~宅男的四個徵兆~ ∠□ ○ ! * \○/ ★    (○ ? ╦╦└□ " ○□═ □   □> ║║√√ ╦══╦ ∥    |\ 一回家就上PTT 每天想正妹 以當好人為樂 忘記正妹虧欠自己 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.159.133.241 ※ 文章網址: http://www.ptt.cc/bbs/java/M.1406292772.A.FB9.html
ssccg:getValue是個method不是constant 07/25 21:33
哈,了解 ※ 編輯: Arim (49.159.133.241), 07/25/2014 23:39:42
kkkmode:getValue能在編譯期間執行完嗎? 07/25 23:57