4.7 - Stream API and Collections
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
What method do you use to collect stream results into a list?
💡 Hint: Think about the main operation associated with gathering items from a stream.
Which collector would you use to split a list into two categories?
💡 Hint: This collector takes a predicate to divide data.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What is the main purpose of the Stream API?
💡 Hint: Think about the primary reason for its introduction into Java.
True or False: Collectors can partition a stream into multiple groups.
💡 Hint: Recall the definition of partitioning in the context of streams.
1 more question available
Challenge Problems
Push your limits with advanced challenges
Write a Java program that takes a list of employees and partitions them into two lists based on salary, one for employees earning above average and one for those below.
💡 Hint: Look at how you can calculate averages and apply them as conditions in partitioning.
Construct a method that reads a list of words and returns a list of unique lengths of those words using the Stream API.
💡 Hint: Think about how you can transform each word before collecting it into a list.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.