Java Stream Operation maxLong(Stream stream)

Here you can find the source of maxLong(Stream stream)

Description

Returns the highest value on a stream of longs

License

Open Source License

Parameter

Parameter Description
stream the Stream of Long to find the maximum of

Return

the highest value on the stream

Declaration

public static long maxLong(Stream<Long> stream) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.stream.LongStream;
import java.util.stream.Stream;

public class Main {
    /**// ww  w.  ja va 2s. c om
     * Returns the highest value on a stream of longs
     *
     * @param stream the Stream of Long to find the maximum of
     * @return the highest value on the stream
     */
    public static long maxLong(Stream<Long> stream) {
        return stream.mapToLong(Long::valueOf).max().getAsLong();
    }

    /**
     * Returns the highest value on a stream of longs
     *
     * @param stream the LongStream to find the maximum of
     * @return the highest value on the stream
     */
    public static long maxLong(LongStream stream) {
        return stream.max().getAsLong();
    }
}

Related

  1. longArray(Stream stream)
  2. longList(LongStream stream)
  3. makeStream(final Object[] array)
  4. mapElementsSizes(IntStream intStream)
  5. maximum(final Stream stream)
  6. maxStringLength(Stream stringStream)
  7. mkString(Stream items, String prefix, String delimiter, String suffix)
  8. nullableStreamOf(Collection nullableCollection)
  9. ofType(Stream stream, Class type)