Online Java Compiler By
JavaTpoint.com
import java.util.*; import java.util.stream.Stream; public class VectorSpliteratorExample1 { public static void main(String arg[]) { //Creating an empty vector object Vector
v1 = new Vector
(); //Adding elemnts to the vector v1.add(10); v1.add(30); v1.add(20); v1.add(40); //Obtain a Stream to the vector Stream
str = v1.stream(); //Getting Spliterator object on vector v1 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