The following example code demonstrates How to Create a Vector of Days of Week in Java.
Here is a program that creates a vector of days of the week in Java.
import java.util.Vector;
public class DayVector {
public static void main(String[] args) {
// create a vector
Vector<String> days = new Vector<String>();
// add elements to the vector
days.add("Monday");
days.add("Tuesday");
days.add("Wednesday");
days.add("Thursday");
days.add("Friday");
days.add("Saturday");
days.add("Sunday");
// display the vector elements using an iterator
System.out.println("Days of the week: ");
for (String day : days) {
System.out.println(day);
}
}
}
This program creates a vector of days of the week and displays its elements using an enhanced for loop.
Further Reading
Understanding Enterprise Java Beans
- Android
- Angular
- ASP.NET
- AWS
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Deep Learning
- Django
- Dot Net Framework
- HTML
- IoT
- Java
- JavaScript
- Kotlin
- Machine Learning
- MEAN Stack
- MERN Stack
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Scratch 3.0
- Solidity
- SQL
- TypeScript
- VB.NET
- Web Designing
- XML
