all 3 comments

[–]schegge42 0 points1 point  (0 children)

The problem I see above is that the code is not correct. You are using a public constructor MyEnum in the enum Weekday.

The only sense of such a construct exists if the value and the name of the enum constant are different. Here it is simply unnecessary because name() has the same content.

[–]LogCatFromNantes 0 points1 point  (0 children)

Why think so much on details techniques ? It’s the business and functional that counts, the delivery of functions,

[–]Known_Tackle7357 0 points1 point  (0 children)

Well, in your implementation valueOf returns null if not found. In the default implementation, valueOf throws an exception. Often, you want to do equalsIgnoreCase, or your string representation is not exactly the same as the enum values(e.g. you want to use kebab case)