开发者

How to get all possible values of an enum in java? (not knowing the specific Enum) [duplicate]

开发者 https://www.devze.com 2023-03-18 00:04 出处:网络
This question already has answers here: How to get all enum values in Java? (8 answers) Closed 5 years ago.
This question already has answers here: How to get all enum values in Java? (8 answers) Closed 5 years ago.

I'd like to create a JComboBox that handles the selection of any Enum given to it. For that I need a method to retrieve all the available values of the Enum passed to the JComboBox. As I don't know the specific Enum I can't call EnumType.valu开发者_C百科es(). I could think of some complicated solutions where supported Enums would have to implement some interface I define, but I guess I am missing a simpler, more general solution. What is the way I should go?


Class.getEnumConstants()

0

精彩评论

暂无评论...
验证码 换一张
取 消