Enumeration (programming)
Enumeration is a special technique used in programming languages. In general it associates each element of an ordered list with a corresponding integer number. This helps to work with descriptive values instead of memorizing numbers.
Java
In the Java programming language a program line looks like this:
- enum Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}
It is important to note, that a Variable defined in a simple way like
- Days day;
is now typesafe. This means, you can only assign enum values to such a variable, not integer numbers.
There is also the possibility to assign each enum Entry additional values and certain functions for enhancement. This is a huge step ahead of C++, where enum Variables are only glorified integers. Java has certain tools for operating with enums and they can be seen more like a full-featured class than a description for integers.