Although using enumerations is type safe, the need to convert an enumeration to a string and vice versa is quite common. And there is no built-in function to do this in Java. And you will end up using valueOf () and toString (). And using this approach will not be much different than using just strings. Because you will need to handle situations where a string cannot be converted to Enum.
Thus, just using static end lines is easy and is common practice, AFAIK.
For example, you will want to interact with the server using some API. You will need to define each method and answer as Enum. And then you will need to add the toString and valueOf methods. Why not just use String?
Vanuan
source share