Enums defined with Array Constant in java

前端 未结 2 399
無奈伤痛
無奈伤痛 2021-01-24 03:12

I\'d like to know if it is possible to define an enum with an Array as a constant; see the following code excerpt.

This does not compile with an illegal start of express

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 03:22

    Yes, you'll just need to initialize them. For example,

    NICKLE(5, new string[]{"five"})
    

提交回复
热议问题