How to nest an Enum inside the value of an Enum

后端 未结 3 1300

I\'d like to know if it is possible in Java to nest Enums.

Here what i\'d like to be able to do :

Have an enum Species made of CAT and DOG wich would grant m

3条回答
  •  广开言路
    2020-12-07 05:04

    Wouldn't you be better doing this with inheritance? Cat and Dog would be subclasses of Species. Persion would be a subclass of Cat and Pitbull would be a subclass of Dog.

    What are trying to achieve by wanting to use Enums?

提交回复
热议问题