import java.util.List; public class Main { public static void main(String[] args) { List<Integer> nums = List.of(1, 2, 3, 4, 5); List<Integer> doubled = nums.stream().map(n -> n * 2).toList(); // TODO: for-each print each element of doubled } }
Output
Click Run to execute, or Check to validate.
Ask questions or share tips about this tutorial
Sign in to join the discussion