This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi Nigel, I checked the article which you have provided but unable to understand what exactly is the int enum pattern?
In prior releases, the standard way to represent an enumerated type was the int Enum pattern: // int Enum Pattern - has severe problems! public static final int SEASON_WINTER = 0; public static final int SEASON_SPRING = 1; public static final int SEASON_SUMMER = 2; public static final int SEASON_FALL = 3;
It means that standard way of implementing enums was as you quoted, that is using integer constants. Note that typesafe enum pattern was still not significantly more difficult, and enum keyword is just some syntactic sugar upon such pattern.
Enums are a great way to implement simple Strategy classes with a fixed set of implementations.
The only drawback of enums is that they can't inherit from other classes (because they already implicitely inherit from the enum base class)..
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus