Java Program to Create a Vector to Store Integer Elements

You are currently viewing Java Program to Create a Vector to Store Integer Elements

Java program to create a vector to store integer elements

// Java program to create a vector to 
// store integer elements

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Vector < Integer > vec = new Vector < Integer > ();

    for (int i = 10; i <= 15; i++)
      vec.add(i);

    System.out.println("Vector Elements:\n" + vec);
  }
}

Output

Vector Elements:
[10, 11, 12, 13, 14, 15]

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply