title: Method stuck in for Loop with If Conditional
body: <p>I am trying to check several entries in a game board by iterating over them in a specific order.
  Now what I noticed is that when the method is called by my junit test, it is stuck in the first for loop and doesn't continue with the next ones, and just returns false, meaning it jumps to the end of the method.
  When I run a test which just needs the first 3 loops, then it works, but another test requires the second loop, which doesn't get executed.</p>
  
  <p>Question: Why is it jumping to the end without first checking the other loops?</p>
  
  <pre><code>    public boolean hasDiagonal(Mark m) {
  
      for (int i = 0; i &lt;= dimension-4; i++) {
          for (int j = 0; j &lt;= dimension-4; j++) {
              for (int k = dimension-1; k == 3; k--) {
                  if (getField(i  , j  , k  ) == m &amp;&amp;
                      getField(i+1, j+1, k-1) == m &amp;&amp;
                      getField(i+2, j+2, k-2) == m &amp;&amp;
                      getField(i+3, j+3, k-3) == m) {
                          return true;
                      //Stops here, if this part doesn't yield true,
                      //it returns false immediately
                  }
              }
          }
      }
  
      //This doesn't get checked
      for (int i = dimension-1; i == 3; i--) {
          for (int j = 0; j &lt;= dimension-4; j++) {
              for (int k = dimension-1; k &lt;= 3; k--) {
                  if (getField(i  , j  , k  ) == m &amp;&amp;
                      getField(i-1, j+1, k-1) == m &amp;&amp;
                      getField(i-2, j+2, k-2) == m &amp;&amp;
                      getField(i-3, j+3, k-3) == m) {
                          return true;
                  }
              }
          }
      }
      return false;
  }
  </code></pre>