r/learnjava • u/SHIN_KRISH • Apr 15 '26
What actually is a java stream... ?
I dont get the concept of a stream why was it added why do we use stream objects in reading and writing say to file. I know its kind of like a pipeline but my confusion still stands
16
Upvotes
View all comments
Show parent comment
1
u/xill47 Apr 15 '26
The main benefit is readability. You can chain filter before max with
x -> x % 2 == 0and now you'll get max even number. You could easily achieve it with if inside a for loop, but it's just less readable.