Kotlinlearncs.online LogoJava
Return to List

Solve: Filter Evens from Array

Created By: Justin Maier
/ Version: 2024.7.0

Given an array of ints named nums, construct an int array named evens that contains just the even values from nums. evens should retain the ordering of elements from nums.

For example, if nums is the array {3, 22, 18, 44, 7, 9, 16}, the array evens should be {22, 18, 44, 16}.

Hint You will need to count the number of even elements in nums before declaring evens.

Related Lessons

Stuck? You may find these lessons helpful: