0 votes
in Java by
What is the difference between Collections and Stream in Java8 ?

2 Answers

0 votes
by (2.8k points)
There are following difference between Collections and Stream:-

1. Stream operations do the iterations internally over the source elements provided, in contrast to Collections where explicit iteration is required.

2. A stream is not a data structure that stores elements but in collection having different types of data structure.

3. Collections have a finite size but streams having not need.
0 votes
by (3.7k points)
There are following differences between Collection API and Stream API:-

1. Collection API was introduced in jdk 1.2 while Stream API is introduced in jdk 1.8
2. Collection objects are created eagerly while Stream API objects are created lazily.
3. Iterate and Consume elements at any number of times for Collection object while iterate and consume elements only one time for Stream object.

Share:- Whatsapp Facebook Facebook

Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.