title: Logical issue with while statement in java method
body: <p>Background Information : </p>
  
  <p>I'm developing a battleship game and in the game I have a 10x10 int[][] (the grid).</p>
  
  <p>I've developed a method which trys to hit a cell on that array or grid as long as the same spot hasn't already been tried. (This is for the computer ofcourse playing against me).</p>
  
  <pre><code>    public boolean randomShot()
  {
      int row;
      int col;
      boolean wasHit = false;
      boolean complete = false;
  
     while (complete == false)
     {
      // Randomly generate a row and column
         row = randomizer.nextInt(ROW_COUNT);
         col = randomizer.nextInt(COLUMN_COUNT);
  
      if(compShots.contains("" + row + col) == false)
      {
          complete = true;
          if(checkHit(row, col) == true)
          {
              wasHit = true;
  
          }
          compShots.add("" + row + col);
      }
  
     }
      return wasHit;
  }
  </code></pre>
  
  <p>The above method works fine and i'm happy with it. </p>
  
  <p>The problem :</p>
  
  <p>I wanted to develop a method that is based off the above method however the computer acts a little smarter in the sense that lets say if he hit row 3 and column 3. Then it would next try to hit row 3 and column 4 etc. however if the next column or row is over the boundary of the board then it would try do it the other way.</p>
  
  <p>The while loop is crashing the game at the moment, any idea why?</p>
  
  <p>This is the method I have to hit the array with a little more brain so to say</p>
  
  <pre><code>    public boolean randomShotClever()
  {
      int row;
      int col;
      boolean wasHit = false;
      boolean complete = false;
  
  
  
     while (complete == false)
     {
  
      // Randomly generate a row and column
         row = randomizer.nextInt(ROW_COUNT);
         col = randomizer.nextInt(COLUMN_COUNT);
  
         if(previousRows.size() == 0 || compShots.contains("" + (previousRows.size() -1) + (previousCols.size() -1) ))       
         {
             finalRow = previousRows.get(previousRows.size());
             if((finalRow + 1) &lt; (ROW_COUNT -1))
             {
                 finalRow = finalRow + 1;
             }
             else 
             {
                 finalRow = row;
             }
  
             finalCol = previousCols.get(previousCols.size());
             if((finalCol + 1) &lt; (COLUMN_COUNT -1 ))
             {
                 finalCol = finalCol + 1;
             }
             else 
             {
                 finalCol = col;
             }
  
             if(compShots.contains("" + finalRow + finalCol) == false)
             {
              complete = true;
              if(checkHit(finalRow, finalCol) == true)
              {
                  previousCols.add(finalCol);
                  previousRows.add(finalRow);
                  wasHit = true;
              }
              compShots.add("" + finalRow + finalCol);
             }
  
         }
  
  
     }
      return wasHit;
  }
  </code></pre>
  
  <p>Thanks in advance for any help offered.</p>