title: Cascading and Reveal for Java
body: <p>I am making a Java Mine Sweeper program. So far everything is going well except for the cascading and reveal. I keep on getting StackOverFlowError. Can someone take a look and help me? Thanks!</p>
  
  <pre><code>public static char[][]revealCell(int xbox, int ybox, char blankboard [] [], char     RevealedBoard [][]){
  
  
  if( RevealedBoard[ybox][xbox]== 'B'){
  blankboard[ybox][xbox]= 'B';
  return blankboard;
  
  }else if( RevealedBoard[ybox][xbox]== '1'){
  blankboard[ybox][xbox]= '1';
  return blankboard;
  }
  
  else if( RevealedBoard[ybox][xbox]== '2'){
  blankboard[ybox][xbox]= '2';
  return blankboard;
  
  }else{
  blankboard[ybox][xbox]= '-';
  
      if( xbox== 0){ // left of the grid 
  
  
          if(ybox==0){
          blankboard= revealCell(xbox+1, ybox, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox+1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox+1, ybox+1, blankboard, RevealedBoard);
          return blankboard;
          }else if( ybox== 7){
          blankboard= revealCell(xbox+1, ybox, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox-1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox+1, ybox-1, blankboard, RevealedBoard);              
          return blankboard;
          }else{
          blankboard= revealCell(xbox+1, ybox, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox-1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox +1, ybox-1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox+1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox+1, ybox+1, blankboard, RevealedBoard);
          return blankboard;
          }
  
      }else if(xbox== 7){// right of the grid
      blankboard= revealCell(xbox-1, ybox, blankboard, RevealedBoard);
  
          if(ybox== 7){
          blankboard= revealCell(xbox, ybox-1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox-1, ybox-1, blankboard, RevealedBoard);
          return blankboard;
          }else if( ybox==0){                                                             
          blankboard= revealCell(xbox, ybox+1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox-1, ybox+1, blankboard, RevealedBoard);
          return blankboard;
          }else{
          blankboard= revealCell(xbox-1, ybox-1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox-1, ybox+1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox-1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox+1, blankboard, RevealedBoard);
          return blankboard;
          }
  
      }else{
          if(ybox== 0){
          blankboard= revealCell(xbox-1, ybox, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox+1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox-1, ybox+1, blankboard, RevealedBoard);
          return blankboard;
          }else if( ybox==7){
          blankboard= revealCell(xbox-1, ybox, blankboard, RevealedBoard);
          blankboard= revealCell(xbox, ybox-1, blankboard, RevealedBoard);
          blankboard= revealCell(xbox-1, ybox-1, blankboard, RevealedBoard);
          return blankboard;
          }else{
      blankboard= revealCell(xbox, ybox-1, blankboard, RevealedBoard);
      blankboard= revealCell(xbox-1, ybox-1, blankboard, RevealedBoard);
      blankboard= revealCell(xbox+1, ybox-1, blankboard, RevealedBoard);
      blankboard= revealCell(xbox-1, ybox+1, blankboard, RevealedBoard);
      blankboard= revealCell(xbox, ybox+1, blankboard, RevealedBoard);
      blankboard= revealCell(xbox-1, ybox, blankboard, RevealedBoard);
      blankboard= revealCell(xbox+1, ybox, blankboard, RevealedBoard);
      blankboard= revealCell(xbox+1, ybox+1, blankboard, RevealedBoard);
  
      }
      }
  
  
  
  }
  return blankboard;
  }
  
  }
  </code></pre>
  
  <p>revealCell is my method and for my actual class at school we have to use recursion. I thought this is what we should do but I am getting errors. </p>