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

Java Practice Exercise

programmingempire

Princites