Online Java Compiler By
JavaTpoint.com
import java.util.*; import java.util.stream.Stream; public class VectorSpliteratorExample2 { public static void main(String arg[]) { Vector
vec = new Vector<>(); vec.addElement("One"); vec.addElement("Two"); vec.addElement("Three"); vec.addElement("Four"); vec.addElement("Five"); //Obtain a Stream to the vector Stream
str = vec.stream(); //Getting Spliterator object on vector vec Spliterator
splitr1 = str.spliterator(); //Printing estimateSize of vector System.out.println("Estimated size: " + splitr1.estimateSize()); System.out.println("Contents of vector:"); //Use forEachRemaining method splitr1.forEachRemaining((n) -> System.out.println(n)); } }
Output