title: Array index out of bounds error in 2d array during linear search
body: <p>I'm writing a program which is suppose to acting like a ticket finder.  It displays a chart of possible seating choices along with their prices and asking if the user would like to select a seat by number or by price.  It works like it's suppose to on the seat by number, but when I try to find a seat by price I get an array index out of bounds error.  I'm confused because it's suppose to be starting a linear search there at zero.  I don't understand why this error is there. </p>
  
  <pre><code>import java.util.Scanner;
  
  public class FindTicket{
    public static void main(String[] args){
      String answer="number";
      Scanner kb=new Scanner(System.in);
      int[][] seats= {
        {10,10,10,10,10,10,10,10,10,10},
        {10,10,10,10,10,10,10,10,10,10},
        {10,10,10,10,10,10,10,10,10,10}, 
        {10,10,20,20,20,20,20,20,10,10}, 
        {10,10,20,20,20,20,20,20,10,10}, 
        {10,10,20,20,20,20,20,20,10,10}, 
        {20,20,30,40,40,40,30,30,20,20}, 
        {20,30,30,40,50,50,40,30,30,20},
        {30,40,50,50,50,50,50,50,40,30}
      };
  
      printChart(seats);
      do{
        System.out.println("Would you like to choose a seat by number, price, or quit?");
        answer = kb.nextLine();
        if(answer.equals("price")){
          sellSeatbyPrice(seats);}
        if(answer.equals("number")){ 
          sellSeatbyNumber(seats);}
        printChart(seats);
      }while(!answer.equals("quit"));
    }
  
    public static void printChart(int[][] seats){
      for (int i=0; i&lt;seats.length; i++)
      {
        for(int j=0; j&lt;seats[0].length; j++)
        {
          System.out.printf("%8d", seats[i][j]);
        }
        System.out.println();
      }
    }
  
    public static int[][] sellSeatbyPrice(int[][] seats){
      Scanner kb=new Scanner(System.in);
      int ticketprice;
      int row = 0, col = 0;
      boolean found = false, seatavaliable=true;
      do{
        System.out.println("What is your prefered ticket price?");
        ticketprice=kb.nextInt();
        while (row&lt;seats.length &amp;&amp; !found){
          do{
            if(seats[row][col] == ticketprice){
              found = true;}
            else{
              col++; }  
          }while(col&lt;seats[0].length &amp;&amp;!found);
          if(seats[row][col] == ticketprice){
            found = true;}
          else{
            row++;} 
        }
        if(found){
          seats[row][col] = 0; }
        else {
          System.out.println("Seat not found at specified price.");
          seatavaliable=false;}
      }while(seatavaliable==false);
  
      return seats;
    }
  
    public static int[][] sellSeatbyNumber(int[][] seats){
      Scanner kb=new Scanner(System.in);
      int row = 0, col = 0;
      int editedrow, editedcol;
      boolean seatavaliable = true;
      do{
        System.out.println("What is your prefered seat number?  Please enter row then column.");
        row=kb.nextInt();
        col=kb.nextInt();
        editedrow = 9-row;
        editedcol = col - 1;
        if(seats[editedrow][editedcol] &gt; 0){
          seats[editedrow][editedcol] = 0;}
        else{
          System.out.println("Seat is not avaliable.");
          seatavaliable=false;}
      }while(seatavaliable==false);
  
      return seats;
    }
  
  }
  </code></pre>