Today I was browsing through some questions on this site and I found a mention of an enum
being used in singleton pattern about purported thread safety benefits
Java lets you restrict variable to having one of only a few predefined values - in other words, one value from an enumerated list.
Using enums
can help to reduce bug's in your code.
Here is an example of enums
outside a class:
enums coffeesize{BIG , HUGE , OVERWHELMING };
//This semicolon is optional.
This restricts coffeesize
to having either: BIG
, HUGE
, or OVERWHELMING
as a variable.