how to get the average from a list in java

64

how to get the average from a list in java -

private double calculateAverage(List <Integer> marks) {
    return marks.stream()
                .mapToDouble(d -> d)
                .average()
                .orElse(0.0)
}

Comments

Submit
0 Comments