Do a reduction that simply returns the current value:
Stream<T> stream;
T last = stream.reduce((a, b) -> b).orElse(null);
More Related Contents:
- How to convert to Java 8 map grouping by Map [closed]
- Java 8 List into Map
- Collection to stream to a new collection
- How to convert a Java 8 Stream to an Array?
- How to sum a list of integers with java streams?
- Java 8 stream’s .min() and .max(): why does this compile?
- Why does Stream not implement Iterable?
- How can I create a stream from an array?
- In Java 8, is there a ByteStream class?
- Sum values from specific field of the objects in a list
- Files.walk(), calculate total size
- Does Stream.forEach respect the encounter order of sequential streams?
- Sort map by value using lambdas and streams
- Grouping by object value, counting and then setting group key by maximum object attribute
- Equivalent of Scala dropWhile
- Why does Stream.allMatch() return true for an empty stream?
- Modifying Objects within stream in Java8 while iterating
- Take every nth element from a Java 8 stream
- Static context cannot access non-static in Collectors
- What Java 8 Stream.collect equivalents are available in the standard Kotlin library?
- How to check if exists any duplicate in Java 8 Streams?
- Finding enum value with Java 8 Stream API
- Java 8, how can I implement a switch statement using streams?
- Picking elements of a list until condition is met with Java 8 Lambdas
- BigDecimal summary statistics
- ‘Optional.get()’ without ‘isPresent()’ check
- Most elegant way to join a Map to a String in Java 8
- How to apply Filtering on groupBy in java streams
- Group sequences of values
- Java 8 stream map to list of keys sorted by values