I would like to be able to define an Enum class that would include another Enum as well as its own values. For example, :
public enum A {
A1, A2, A3;
}
public enum B{
B1, B2, ...(somehow define references to all values in enum A)
}
such that any values contained in enum B must be either defined initself (such as B1, B2) or any values of enum A.
Thanks,
Such that B
is the union of A
and B
? That's not possible without B
extending A
, which is not supported in java. The way to proceed is to create an enum
which contains the combined values of A
and B
, e.g.,
enum C {
A1, A2, A3, B1, B2;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With