title: Trying to get my for loop working
body: <p>So at this point I have no idea why my <code>for</code> loop doesn't work. It's probably just an minor mistake but I cant find it so I'd appreciate your help. This is how it looks like:</p>
  
  <pre><code>int[] values = new int[array1.length];
  for (int i = 0; i &lt; array1.length; i++) {
      for (int x = 0; x &gt;= array1[i][0] &amp;&amp; x &lt;= array1[i][2]; x++) {
          for (int y = 0; y &gt;= array1[i][1] &amp;&amp; y &lt;= array1[i][3]; y++) {
              values[i] += array2[x][y];
          }
      }
  }         
  </code></pre>
  
  <p>Numbers I'm using to test it on and some context:</p>
  
  <p>Both arrays are 2D,
  <code>array1</code>  looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/LSeAu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LSeAu.png" alt="array1"></a></p>
  
  <p>(<code>array1.length</code> = <code>8</code>) and <code>array2</code> like this:</p>
  
  <p><a href="https://i.stack.imgur.com/SJxOG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SJxOG.png" alt="array2"></a></p>
  
  <p><code>array1</code> holds coordinates of left-top and right-bottom corner of the area in <code>array2</code> so for example <code>0 0 2 1</code> are coordinates for <code>array2[0][0]</code> and <code>array2[2][1]</code> and I'm trying to get my <code>for</code> loop to add all numbers in the area. So for this example it would add those four numbers:</p>
  
  <p><a href="https://i.imgur.com/DmZg5M8.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/DmZg5M8.png" alt="enter image description here"></a></p>
  
  <p>My output is: <code>3 0 0 0 0 0 0 0</code></p>