Posts

Showing posts with the label Intermediate And Terminal Operations

Learn Java 8 Stream Intermediate And Terminal Operations with Example

Image
Java is Object Oriented Programming language, being object-oriented is not bad, but it brings a lot of verbosity to the program. Java 8 introduced new libraries and programming styles, for example, functional interfaces, lambda expressions, and streams. These bring functional-style programming to the object-oriented programming capabilities of Java. Java Functional Interface and Lambda Expression help us write smaller and cleaner code by removing much boilerplate code.  Java Stream Intermediate operations and Terminal operations The intermediate operation will transform a stream into another stream, such as a map(MapperFn) or a filter(Predicate). The Terminal operation will produce a result or side-effect, such as count() or forEach(Consumer). All intermediate operations will NOT be executed without a terminal operation at the end. So the pattern will be: stream() .intemediateOperation1() .intemediateOperation2() ....................... .intemediateOperationN() .ter