This is a simple Java console application that demonstrates the use of Enums and switch statements to classify days of the week as either weekdays or weekends.
- Enums: Special types that represent fixed sets of constants (in this case, days of the week).
switchexpressions: Modernswitchsyntax using arrow notation.- Input handling: Using
Scannerto read user input from the console. - Exception handling: Gracefully managing invalid enum input with a
try-catchblock.
| Concept | Description |
|---|---|
enum |
Used to define a fixed set of named constants (MONDAY, TUESDAY, etc.) |
switch |
Determines if a day is a weekday or weekend |
Scanner |
Captures user input from the command line |
try-catch |
Handles cases where user input doesn't match a valid enum |
Enter the day of the week: saturday
it is a weekend