title: Java How to iterate through an array of doubles and round to nearest whole number
body: <p>Tried a couple of things. I need to iterate through an array of doubles. And round each element to the nearest whole number. Any ideas where I'm going wrong ?         </p>
  
  <pre><code>     for(int i = 0; i &lt; example.length; i++){
       Math.round(example[i]);
       }
  
  
       int[] example1 = new int[example.length];
       for(int i=0; i&lt;example1.length; i++) {
           Math.round(example1[i]);
           example1[i] = (int) example[i]; 
       }
  </code></pre>