Returns an OptionalInt describing the maximum element of this stream, or an empty optional if this stream is empty. This is a special case of a reduction.
Examples
package com.logicbig.example.intstream;
import java.util.stream.IntStream;
public class MaxExample {
public static void main(String... args) { IntStream intStream = IntStream.range(1, 5); int i = intStream.max().orElse(-1); System.out.println(i); } }