我正在从 Android 中的本机代码接收 long 或 int 形式的返回值,我想将其转换或与 enum 匹配,以进行处理.是否可以 ?怎么样?
I am receiving return value in the form of long or int from Native code in Android, which I want to convert or match with enum, for processing purpose. Is it possible ? How?
如果你可以完全控制值和枚举,并且它们是顺序的,你可以使用枚举序数值:
If you have full control of values and enums, and they're sequential, you can use the enum ordinal value:
enum Heyo
{
FirstVal, SecondVal
}
...later
int systemVal = [whatever];
Heyo enumVal = Heyo.values()[systemVal];
int againSystemVal = enumVal.ordinal();
这篇关于如何将int与枚举匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!