[英]Enum type conversion to int
我正在嘗試使用以下代碼...我正在使用的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;
}
我該如何使用
帳戶類型
作為整數。
integerToDB(accountType.getValue());
?
由於您的枚舉實現了getValue
方法,因此可以使用accountType.getValue()
來獲取存儲在accountType
的整數值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.