Java streams 15. Stream factory methods

The Stream interface factory methods are the methods that create a Stream object. Their implementation includes a call to a class constructor and that is the advantage of factory methods: they can do much more than a constructor. They can return any type as needed, not just the instance of the constructed class. They can control the number of instances, use a pool, re-use the instances, and similar. They can have…