LogiQuest
Back to Java 8 Features
8

What is the output of the following program?

import java.util.*;
public class Main {
    public static void main(String[] args) {
        List<Integer> nums = List.of(1, 2, 3, 4, 5);
        System.out.println(nums.stream().filter(n -> n % 2 == 1).mapToInt(n -> n).sum());
    }
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.