Java Streams - Stream API in Java8 #java8 #streams #shorts

preview_player
Показать описание
Important Features introduced in Java 8 - Streams in Java
Stream API
Collectors class
ForEach() method

Stream API
The Stream API is used to process collections of objects.
A stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result.
Streams don’t change the original data structure, they only provide the result as per the pipelined methods.

Collector Class
Collectors is mostly used with Stream API as a final step.
It provides reduction operations, such as accumulating elements into collections, summarizing elements according to various criteria, etc.

ForEach Method
Java 8 provides a new method forEach() to iterate the elements. It is defined in Iterable and Stream interface.
It takes a single parameter which is a functional interface - lambda expression can be passed as an argument.

#java8 #java8features #streamapi #javastreams #foreachmethod #collectorclassjava #streams
Рекомендации по теме