

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Enum for days of week in Java
To set enum for days of the week, set them as constants
enum Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }
Now create objects and set the above constants −
Days today = Days.Wednesday; Days holiday = Days.Sunday;
The following is an example −
Example
public class Demo { enum Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } public static void main(String[] args) { Days today = Days.Wednesday; Days holiday = Days.Sunday; System.out.println("Today = " + today); System.out.println(holiday+ " is holiday"); } }
Output
Today = Wednesday Sunday is holiday
- Related Questions & Answers
- Java Program to get date for all the days of the current week
- How to create a random sample of week days in R?
- Get the week number in MySQL for day of week?
- Enum in Java
- Get the day of week for a particular date in Java
- Python Pandas - Create a PeriodIndex and get the days of the week
- Enum Methods in Java
- Enum constructor in Java
- Get Day Number of Week in Java
- Java Program to get display name for Day of Week in different locale
- The equals and == operator for Enum data type in Java
- PHP program to find number of days in every week between two given date ranges
- Gadget Updates for the Week
- enum - Support for enumerations in Python
- Days till End of Year in Java
Advertisements