The stream() method help us to get value contain by OptionalInt as IntStream. If a value is present, method returns a sequential IntStream containing only that value, otherwise returns an empty IntStream.
public IntStream stream()
Parameters: This method accepts nothing.
Return value: This method returns the optional value as an IntStream.
Below programs illustrate stream() method:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.