You are viewing a single comment's thread. Return to all comments →
Java streams
public static void plusMinus(List<Integer> arr) { long negValues = arr.stream().filter(x -> x < 0).count(); long posValues = arr.stream().filter(x -> x > 0).count(); long zeroValues = arr.stream().filter(x -> x == 0).count(); long length = negValues + posValues + zeroValues; System.out.println((double)posValues/length); System.out.println((double)negValues/length); System.out.println((double)zeroValues/length); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
Java streams