DayOfWeek values() method in Java with Examples
The values() method of java.time.DayOfWeek is an in-built function in Java which returns an array containing the days of the week, e.g. MONDAY, TUESDAY and so on, in the order they are declared.
public static DayOfWeek values()
DayOfWeek week = DayOfWeek.values()
Parameters: This method does not accepts any parameters.
Return Value: The function returns an array containing the days of the week in the order they are declared.
Below programs illustrate the above method:
MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY
MONDAY has int value - 1 TUESDAY has int value - 2 WEDNESDAY has int value - 3 THURSDAY has int value - 4 FRIDAY has int value - 5 SATURDAY has int value - 6 SUNDAY has int value - 7
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.