xxxxxxxxxx
// Java code for IntStream of(int... values)
// to get a sequential ordered stream whose
// elements are the specified values.
import java.util.*;
import java.util.stream.IntStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// Creating an IntStream
IntStream stream = IntStream.of(-7, -9, -11);
// Storing the count of elements in IntStream
long total = stream.count();
// Displaying the count of elements
System.out.println(total);
}
}
xxxxxxxxxx
An IntStream interface extends the BaseStream interface in Java 8. It is a sequence of primitive int-value elements and a specialized stream for manipulating int values. We can also use the IntStream interface to iterate the elements of a collection in lambda expressions and method references.Jul 13, 2563 BE