私はint型を返す関数を持っています。しかし、私はTAX列挙の価値しか持っていません。enum値をintに変換するには?
TAX列挙型の値をint型にキャストするにはどうすればよいですか?
public enum TAX {
NOTAX(0),SALESTAX(10),IMPORTEDTAX(5);
private int value;
private TAX(int value){
this.value = value;
}
}
TAX var = TAX.NOTAX; // This value will differ
public int getTaxValue()
{
// what do do here?
// return (int)var;
}
[int型列挙型に一致する方法]の可能な重複(http://stackoverflow.com/questions/7996335/how-to-match-int-to-enum) – malat