title: how to find the sum of all the values in an int[][] Java?
body: <p>i have an array of integer arrays 'int pixels[][]'</p>
  
  <p>and i want to find the sum of all of them so i can find the average pixel value </p>
  
  <p>this will be used so that i can set the average value of a pixel to be the threshold value for a pbm image</p>
  
  <p>if the value if above threshold i will export a white pixel if its below i will export a black one (just to give some context)</p>
  
  <p>i assume the code below is not correct at all as the output it 6.0 but i think its something like this</p>
  
  <pre><code>   double threshold = 0;
     for(int i = 0; i &lt; pixels.length; i++)
     {
         threshold += (double)pixels[i][i];
     }
     System.out.print(threshold);
  </code></pre>