Override valueof() and toString() in Java enum

前端 未结 7 1647
傲寒
傲寒 2020-12-02 12:36

The values in my enum are words that need to have spaces in them, but enums can\'t have spaces in their values so it\'s all bunched up. I want to override

7条回答
  •  無奈伤痛
    2020-12-02 13:12

    You still have an option to implement in your enum this:

    public static > T valueOf(Class enumType, String name){...}
    

提交回复
热议问题