← All Exercises

Stream Filter and Collect

basicjava~15min

Background

Stream API enables declarative data processing with potential for parallelization.

Problem

Given a list of integers, use Stream API to filter even numbers and collect their squares into a list.

Input

A list of integers

Output

A filtered and transformed list

Sample tests

Sample 1

Input: [1,2,3,4,5,6]
Expected: [4,16,36]

Your solution

Learning objective

Learn Java Stream API and functional operations