Java getting the Enum name given the Enum Value

前端 未结 5 491
轻奢々
轻奢々 2020-12-15 14:55

How can I get the name of a Java Enum type given its value?

I have the following code which works for a particular Enum type, can I make it more

5条回答
  •  时光说笑
    2020-12-15 15:29

    Try, the following code..

        @Override
        public String toString() {
        return this.name();
        }
    

提交回复
热议问题