I've switched from using constants for Strings to using enums. Many times I need the String
representation of the enum (for logging, to pass to an API that requires a String
, etc).
With String
constants, you can just pass the String value, but with enums you have to call toString()
. Is there a way you can "default" to the String value when supplying the enum variable?
As many posters have commented, perhaps one shouldn't be using enums if you frequently need the String
representation.