You are viewing a single comment's thread. Return to all comments →
Using Streams: double len = arr.size(); long zero = arr.stream().filter(x-> x==0).count(); long positive = arr.stream().filter(x-> x>0).count(); long negative = arr.stream().filter(x-> x<0).count(); double result1= zero/len; double result2= positive/len; double result3= negative/len; System.out.println(String.format("%.6f", result2)); System.out.println(String.format("%.6f", result3)); System.out.println(String.format("%.6f", result1));
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 →