Java enums let you specify global constants in one place, mitigate security risks and
Enums let Java developers define constants and create singletons and avoid defining PUBLIC STATIC FINAL objects.
Enums can also hold data and associate different behaviour to each Enum constant. This can reduce code and maintenance dramatically. Use of Enum constants can also help mitigate some security issues.
This provides two immutable constants. Once upon a time these would have been PUBLIC STATIC FINAL objects e.g
This let an IDE such as Eclipse warn of typing mistakes and human memory bugs but resulted in classes with vast numbers of strings that had, for safety, to be unique throughout the application. The situation was even worse with Integers as some developers would remember the value of the constant and use the value not the constant. This resulted in bugs other developers loved to spend hours tracking down: after which they might track down the perpetrator and inform them forcefully of the error of their ways.
Enums allow packaging constants needed by a class or system in one place in compact easily maintainable fashion.
No more worrying about capitalisation (I recall a typo in a manual that cost three people a week of debugging till someone suggested changing the initial latter of a string from lowercase to uppercase, in contradiction of the manual).
Enum constants can also hold data for example
One can also create different behaviours for each constant by defining an abstract function eval on the class and implementing it for each constant.
Enums can be confusing at first but eliminate methods like
Similarly creating an eval() method for each constant can radically simplify the design of an application.
Since an Enum constant is immutable it can safely be included in SQL calls without creating an SQL injection vulnerability.
You can see more of my technological musings on http://digitalsteampunk.blogspot.co.uk/