Ajith Kallambella

Subscribe to Ajith Kallambella: eMailAlertsEmail Alerts
Get Ajith Kallambella: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Top Stories by Ajith Kallambella

To enumerate means to itemize or to list. In the world of programming, enumerations, enums for short, are used to represent a finite set of values (constants) that a variable can attain. In other words, it defines the domain of a type. For instance, different states of a fan switch - off, low, medium, and high - make up an enumeration. Since the first release of Java, programmers have been complaining about the lack of core language support for enumerated types. After all, Java improvised on the shortcomings of C++ and touted type safety, so it was only natural for the developer community to expect support for a true enum-type. During what seemed like an eternally long wait, many ad-hoc enum representations evolved and most of them shared a common premise - modeling enumerations based on a primitive type, usually an int; see Listing 1 for an example. Although prac... (more)