Therefore, go for the meaning : the Strings are more meaningful than numbers, so use the String . Show activity on this post. Both have advantages. If you store them by their Integer value, then you must be careful editing your enumeration later on in your project.
Read moreHow do I assign a string value to an enum?
Parse the string value into an Enum Enum. Parse(Type enumType,string value) – This method directly parses the string representation of the name or numeric value of enum member into enumType object. If the string representation of the name is not found, then it will give the exception.
Read moreCan I store string in enum?
Enum constants can only be of ordinal types ( int by default), so you can’t have string constants in enums .
Read moreCan enum values be strings?
Every enum has both a name() and a valueOf(String) method . The former returns the string name of the enum, and the latter gives the enum value whose name is the string.
Read moreAre enums just integers?
The C standard grants the freedom to use different integer types to represent different enumeration types, but most compilers just use int to represent all enumeration types . Treating enumerations as just integers leads to some useful behaviors.
Read moreCan Java enums be numbers?
Not directly as you’ve written, i.e., where an enum value equals a number, but yes indirectly as shown in Ben S’s link.
Read moreCan enum store numbers?
Instead you can have integer values to the elements of an enum.6 Ağu 2019
Read more