简体   繁体   English

在java中将一种枚举设置为另一种枚举类型的枚举

[英]Set one kind of enum to another enum kind of enum in java

I have Enum defined in entity class as well as in Response class.我在实体类和响应类中定义了枚举。 Both Enum are same kind.两个枚举都是同一种。 I want o set value to one Enum to another Emum.我想将一个 Enum 的值设置为另一个 Emum。 Below are sample code.下面是示例代码。 示例代码<\/a>

"

It would be better if you declare enum Type<\/code> out of Entity<\/code> or Response<\/code> class.如果您将enum Type<\/code>声明为Entity<\/code>或Response<\/code>类会更好。 Then you could use same enum for both classes.然后你可以对两个类使用相同的枚举。

You can declare an enum at any of three levels:您可以在三个级别中的任何一个级别声明枚举:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM