DEV Community

Discussion on: Improving your reasoning with Arrays in java

Collapse
 
xgourmandin profile image
Xavier Gourmandin

And for those interested in the one liner, more functional approach :

return Arrays.stream(a).reduce(0, (partial, i) -> i%2==0?partial-i:partial+i);