Stream Gatherers | Java 22 New Feature

Поділитися
Вставка
  • Опубліковано 18 чер 2024
  • In this video we explore Stream Gatherers included in Java 22 release. Stream gatherers enhance stream API to support custom intermediate operations. This will allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations.. Here's how to create Gatherers from an initializer, integrator, finisher, and combiner.
  • Наука та технологія

КОМЕНТАРІ • 5

  • @hba6018
    @hba6018 5 днів тому +1

    Why not List.of(...) to create a List? you are working with streams

    • @Code.Wizzard
      @Code.Wizzard  5 днів тому

      Good point. List.of() is more optimised for this scenario since it provides an immutable list. Thanks for the feedback. Although Arrays.asList() provides a fixed size list, you can still replace an element in an existing index with another one using set operation

  • @nayrban2187
    @nayrban2187 5 днів тому +1

    Why use generic T instead of String?

    • @PatrickUdochukwu
      @PatrickUdochukwu 5 днів тому +1

      To make it generic, so you can use an type of list in future

    • @Code.Wizzard
      @Code.Wizzard  5 днів тому

      Thanks Patrick for answering. Building Gatherers with generics will allow us to use the same gatherer for other types. For example we can use the same fixed window gatherer for list of Person objects instead of String.