Java Program to Traverse the Vector Collection Using Spliterator() Method

Java Program to Traverse the Vector Collection Using Spliterator() Method

Java Program to Traverse the Vector Collection Using Spliterator() Method

// Java program to traverse the Vector collection 
// using Spliterator

import java.util.*;

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

    vec.add(10);
    vec.add(20);
    vec.add(30);
    vec.add(20);
    vec.add(12);

    Spliterator < Integer > items = vec.spliterator();

    System.out.println("Vector Elements:");
    items.forEachRemaining((n) -> System.out.println(n));
  }
}
Vector Elements:
10
20
30
20
12

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

Share on:

Leave a Comment