What is the reason for java.lang.IllegalArgumentException: No enum const class even though iterating through values() works just fine?

前端 未结 4 1238
执念已碎
执念已碎 2020-12-05 12:55

This question is basically an extension of my previous question . I asked the previous question to be sure that the Enum constants are populated when the class loads . Here\

4条回答
  •  不思量自难忘°
    2020-12-05 13:26

    Instead of defining: COLUMN_HEADINGS("columnHeadings")

    Try defining it as: COLUMNHEADINGS("columnHeadings")

    Then when you call getByName(String name) method, call it with the upper-cased String like this: getByName(myStringVariable.toUpperCase())

    I had the same problem as you, and this worked for me.

提交回复
热议问题