Interfaces vs. enums

前端 未结 5 1442
名媛妹妹
名媛妹妹 2021-02-07 00:24

Between interfaces and enums, which is better for declaring constants? Why is it so?

5条回答
  •  别跟我提以往
    2021-02-07 01:18

    Its always better to use Enums to declare constants as the objective of interfaces are on a totally different level. Yes, there are lots of interfaces which have a public static final constants, but I feel that enums exclusive job is to provide you these constants.

提交回复
热议问题