Files
Knowledge/0 编程/java/Enum+与+int+互转+d3067cb7-19fe-4b28-917c-dc27f7b54923.md
T

26 lines
189 B
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Enum 转 int
`C.ordinal()`
 
 
## int 转 Enum
只能遍历
```Plain Text
for (MyEnum type : values()) {
if (type.getId() == id) {
return type;
}
}
return null;
```