Related Topics

JAVA Programming
enum DayOfWeek {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
}
In this example, DayOfWeek
is an enumerated type with seven possible values representing the days of the week.
You can access the values of an enumerated type using the dot notation, like this:
DayOfWeek today = DayOfWeek.MONDAY;
You can also use the values()
method of the Enum
class to get an array of all the values in an enumerated type:
DayOfWeek[] daysOfWeek = DayOfWeek.values();
The Enum
class provides a number of additional features for working with enumerated types, such as implementing interfaces and overriding methods. Enumerated types can also have constructors, fields, and methods like any other Java class.




Popular Category
Topics for You
Go through our study material. Your Job is awaiting.