title: Why am I receiving an ArrayIndexOutofBoundsException when trying to check for mills?
body: <p>I'm working on a nine men morris GUI and the method I'm currently stuck on is checking for mills. I understand that the pieces are outside bounds however shouldn't it just return false and work fine anyways? How do I go about checking for pieces that could potentially be outside of the board?</p>
  <pre><code>private boolean isMill(ActionEvent e) {
          
          for(int r = 0; r &lt; this.board.length; r++) {
              for(int c = 0; c &lt; this.board[r].length; c++) {
                  
                  if(this.board[r][c] == e.getSource()) {
                      
                      JButton piece = this.board[r][c];
                      
                      JButton abovePiece = this.board[r + 1][c];
                      JButton belowPiece = this.board[r - 1][c];
                      JButton rightPiece = this.board[r][c + 1];
                      JButton leftPiece = this.board[r][c - 1];
                      
                      JButton afterAbovePiece = this.board[r + 2][c];
                      JButton afterBelowPiece = this.board[r - 2][c];
                      JButton afterRightPiece = this.board[r][c + 2];
                      JButton afterLeftPiece = this.board[r][c - 2];
                      
                      if(this.isBlack(piece)){
                          
                          if(this.isBlack(abovePiece) &amp;&amp; this.isBlack(afterAbovePiece)) {
                              return true;
                          }
                          
                          if(this.isBlack(belowPiece) &amp;&amp; this.isBlack(afterBelowPiece)) {
                              return true;
                          }
                          
                          if(this.isBlack(rightPiece) &amp;&amp; this.isBlack(afterRightPiece)) {
                              return true;
                          }
                          
                          if(this.isBlack(leftPiece) &amp;&amp; this.isBlack(afterLeftPiece)) {
                              return true;
                          }
                          
                          if(this.isBlack(abovePiece) &amp;&amp; this.isBlack(belowPiece)) {
                              return true;
                          }
                          
                          if(this.isBlack(leftPiece) &amp;&amp; this.isBlack(rightPiece)) {
                              return true;
                          }
                          
                          // TODO: Same thing but for whtie pieoces
                          
                      }
                      
                  }
                  
              }
              
          }   
          
          return false;
          
      }
  </code></pre>