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.
Syntax:
public IntStream stream()
Parameters: This method accepts nothing.
Return value: This method returns the optional value as an IntStream.
Below programs illustrate stream() method:
Program 1:Output:👁 Image Program 2: