Enumerations in Java
Enumerations allow you to define a fixed set of constants that represent possible values for a variable. They provide a type-safe way to work with these values and can improve the clarity and readability of your code.
Example code:
csharp
public enum DayOfWeek {
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
}
DayOfWeek today = DayOfWeek.MONDAY;
System.out.println("Today is " + today);
No comments:
Post a Comment