top of page

Java 8 stream hidden features

  • Writer: Anand Nerurkar
    Anand Nerurkar
  • Apr 25, 2024
  • 1 min read
ree

we can make use of

Stream.ofNullable - return the same result as above

ree

2.stream.iterate()- create infinite stream, creating certain pattern like 0,2,4,6,8.......

ree

This create infinite stream


ree

To break this infinite stream, we need to add termination, so we make use of limit as below

ree

Collectors.collectingAndThen

ree

to perform addtional transformation on collectors.

for ex: avg salary of employee

ree

stream.takeWhile, stream.dropWhile

ree

ree

ree

Collectors.teeing()

allows you to collect 2 collectors parallel and combine the result.

ree
ree

ree

Collectors.partioningBy

allows you to partition a stream by certain condition

ree
ree

 
 
 

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
  • Facebook
  • Twitter
  • LinkedIn

©2024 by AeeroTech. Proudly created with Wix.com

bottom of page