Java 8 lambda expression evaluation

Viewed 297

I have a method similar to the following one:

public double[] foo(double[] doubleArray) { 
    DoubleStream stream = Arrays.stream(doubleArray);

    return stream.map(s -> s / stream.sum()).toArray();
}

What is the complexity of this method? How many times will DoubleStream's sum method be executed? Once or O(n) times, with n = doubleArray.length?

1 Answers
Related