|
|
|
|
Languages like C and C++ have the ability to specify a set of values, each one of which typically has a unique value, and is identified by its name, rather than the associated value. For example: enum size { SMALL, MEDIUM, LARGE, XLARGE };
// Declares a type, called size
enum size mySize = LARGE; // Defines a variable, called mySize, of type size, and // assigns it a value LARGE. Note that you don't need to know the specific value of any of these 'enumerated values'. Instead, you use its (much more mnemonic) name. Until Java 5, Java did not provide good support for such a feature, but Java 5 added that support. |
|
This page was last modified on 02 October, 2007 |