Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Display weekday names in Java
To display weekday names in Java, use the getWeekdays() method.
For that, firstly import the following package.
import java.text.DateFormatSymbols;
Now, create a string array and get all the weekday names using the getWeekdays() method.
String[] weekDays = new DateFormatSymbols().getWeekdays();
Example
import java.text.DateFormatSymbols;
public class Demo {
public static void main(String[] args) {
String[] weekDays = new DateFormatSymbols().getWeekdays();
System.out.println("Weekday names...");
for(String days: weekDays){
System.out.println(days);
}
}
}
Output
Weekday names... Sunday Monday Tuesday Wednesday Thursday Friday Saturday
Advertisements