Stream is a tool that uses functional programming to perform complex operations on a collection class.
1.collect (ToList ())
Generate a list from the values in the Stream
List<string> collected = Stream.of ("A", "B", "C")
2.map
Converts a value in a stream to a new stream
List<string> collected = Stream.of ("A", "B", "Hello") , string.touppercase ()) . Collect (ToList ());
3.filter
Qualifying values are preserved
list<string> beginningwithnumbers = Stream.of ("A", "1abc", "ABC1") , IsDigit (Value.charat (0 )) . Collect (ToList ());
4.flatmap
First flatten the input data and then map the values after the flat
5.max, Min
Track Shortesttrack = tracks.stream ( ), track.getlength ()) . get ();
Summarize:
? Internal iterations give more control to the collection class.
? Like Iterator, Stream is an internal iterative approach.
? Many common collection operations can be accomplished by combining LAMBDA expressions with the methods on the Stream.
Reference: "Java8 functional Programming"
Stream class of Java8