title: How to round average in Java stream?
body: <p>I want to calculate the average of a list of integers and then round the result to half up (i.e. >= .5 is  rounded to nearest integer up and &lt; .5 is rounded to the nearest integer down). How do I do this with Java stream ?</p>
  
  <pre><code>public static void main(String [] args){
      List&lt;Integer&gt; values = new ArrayList&lt;&gt;();
      values.add(60);
      values.add(30);
      values.add(20);
  
      double avg = values.stream().mapToInt(a -&gt; a).average().getAsDouble();
  
      System.out.println(avg);
  }
  </code></pre>
  
  <p>I was hoping for something like </p>
  
  <pre><code>...average().round(RoundingMode.HALF_UP).getAsInt();
  </code></pre>