Posts: 266
Threads: 239
Joined: Apr 2011
Dear sir, please sir guide me that how enumeration is done in java??
for example that we want to the names of months and constrain a person not to selected name or phrase other that the name of the month.
for this method what should we do???
Posts: 9,583
Threads: 8,089
Joined: Apr 2011
An enum type is a type whose fields consist of a fixed set of constants. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.
Because they are constants, the names of an enum type's fields are in uppercase letters.
In the Java programming language, you define an enum type by using the enum keyword. For example, you would specify a days-of-the-week enum type as:
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
}
Note: for further details following web link can help you
http://download.oracle.com/javase/tutori.../enum.html