Naming of enums in Java: Singular or Plural?

前端 未结 2 1820

Is there an \"official\" recommendation of how to name Java enums?

enum Protocol { HTTP, HTTPS, FTP }

or

enum Protocols { HTTP,         


        
2条回答
  •  庸人自扰
    2021-01-31 01:35

    Enums in Java (and probably enums in general) should be singular. The thinking is that you're not selecting multiple Protocols, but rather one Protocol of the possible choices in the list of values.

    Note the absence of plurals: http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

提交回复
热议问题