Why shouldn't Java enum literals be able to have generic type parameters?

前端 未结 7 2198
无人共我
无人共我 2020-11-27 10:09

Java enums are great. So are generics. Of course we all know the limitations of the latter because of type erasure. But there is one thing I don\'t understand, Why can\'t I

7条回答
  •  我在风中等你
    2020-11-27 10:24

    Becasue "enum" is the abbreviation for enumeration. It's just a set of named constants that stand in place of ordinal numbers to make the code better readable.

    I don't see what the intended meaning of a type-parameterized constant could be.

提交回复
热议问题