streams

Showing posts with label streams. Show all posts
Showing posts with label streams. Show all posts

Streams vs Collections in Java


 Streams vs Collections


Collections
Streams
The collections are used to store & group data in data structures like List, Set, Map...etc.Streams are used to perform complex operations like filtering, matching, mapping, etc... on stored data
Data modification can be done. You can add or remove data from a CollectionData cannot be modified
External iterations need to be done Internal iterations are being used
Collections can be traversedStreams can be traversed only once. If you need another traverse, you need to create a new stream
Collections are eagerly constructedStreams are lazily constructed