LogiQuest
Back to Generics
10

What is the output of the following program?

public class Main {
    static double sum(java.util.List<? extends Number> list) {
        double s = 0;
        for (Number n : list) s += n.doubleValue();
        return s;
    }
    public static void main(String[] args) {
        System.out.println(sum(java.util.List.of(1, 2, 3)));
    }
}
Medium

Discussion (0)

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

Log in to join the discussion.