[问题] switch 后面接 constant

楼主: Arim (象山下智久)   2014-07-25 20:52:49
各位版友好
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,请问我这样写法是错在哪里呢?
谢谢
作者: ssccg (23)   2014-07-25 21:33:00
getValue是个method不是constant
作者: kkkmode (kkk)   2014-07-25 23:57:00
getValue能在编译期间执行完吗?

Links booklink

Contact Us: admin [ a t ] ucptt.com