我正在尝试使用以下代码。。。我使用的Enum类是
public enum AccountType {
kAccountTypeAsset(0x1000),
kAccountTypeAssetFixed(0x1010),
private int value;
private AccountType(int value)
{
this.value = value;
}
public int getValue()
{
return value;
}
}
public AccountType accountType = kAccountTypeAsset;
integerToDB(accountType);
...
/*************************/
public Object integerToDB (Integer i )
{
if(i == -1)
{
return null;
}
return i;
}
我如何使用
accountType
作为整数。
integerToDB(accountType.getValue());
?
由于您的枚举实现了getValue
方法,因此可以使用accountType.getValue()
来获取存储在accountType
中的整数值。