public enum MyEnum { EnumValue1, EnumValue2 } MyEnum enumValue = (MyEnum) x; //Doesn't work???
How can I cast int as enum?
MyEnum.values()[x] Try it like this. However, x must be 0 or 1. In Java, enum is a class and enum values are objects. So it's impossible to cast int or Integer as enum.
589 Scrap text information after the "View More" button when searching in the Yahoo! News search window
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
581 PHP ssh2_scp_send fails to send files as intended
578 Understanding How to Configure Google API Key
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.