Nearly every Java app iterates collections, making operations on its elements, searching, changing them, sorting and so on. Streams are more readable way of doing this. Streams operations are to some excent similar to SQL Query operations – you can select, filter, order items in collection.
What is a stream
Stream is a sequence of elements. This is simply taken – another abstraction for an array or list.
Follow this post to quickly get the idea behind it. Read Oracle article to learn details.
How to get a stream?
As simple as that:
List<String> list =new ArrayList<String>(); Stream<String> stream =list.stream();
What operations can you do on a stream?
– intermediate operations: they are called on a Stream type, perform requested operations, and return modified stream. So you can…
View original post 883 more words