Java Program to Count the Items of a Vector Collection

Java program to count the items of a Vector collection

// Java program to count the items of 
// Vector collection

import java.util.*;

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

    vec.add(10);
    vec.add(20.5);
    vec.add(true);
    vec.add("Hello World");

    System.out.println("Size of vector collection: " + vec.size());
  }
}

Output

Size of vector collection: 4
Share on:

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

Leave a Comment