enum has valueOf(string)
method to get enum constant and the same type of method present in java.lang.Enum
class having name valueOf(enumClas
The reason the Enum.valueof()
method is included is that it works with any enum
. By contrast, the enum
valueof
method for a specific method only works for that specific enum
... since enum
classes cannot be used polymorphically.
Obviously the Enum.valueOf(...)
method is only really useful if you are implementing code that needs to work for multiple enum
types ... and generics don't cut it.