title: Bus Seat Reservation. I have no idea how to make the code exit the program when I enter a negative number.(Index 1 out of bounds for length 1)
body: <p>Here is my code so far:</p>
  <pre><code>import java.util.*;
  public class BusReservation {
      public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          boolean response = true;
          String[] user_respo;
          String[] Rows = { &quot;Row 1 &quot;, &quot;Row 2 &quot;, &quot;Row 3 &quot;, &quot;Row 4 &quot;, &quot;Row 5 &quot;, &quot;Row 6 &quot;, &quot;Row 7 &quot;, &quot;Row 8 &quot;, &quot;Row 9 &quot;, &quot;Row 10 &quot;};
          String [][] table = 
          {
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
                  {&quot;  |*&quot;, &quot;   *   &quot;,&quot;   *  &quot;, &quot;   *  &quot;},
          };
          do {
              System.out.println(&quot;Bus Seat Reservation&quot;);
              String[] columns = { &quot; &quot;,&quot;Col 1&quot;,  &quot;Col 2&quot;,  &quot;Col 3&quot;,  &quot;Col 4&quot; };
              for (int i = 0; i &lt; columns.length; i++) {
                  System.out.print(&quot;\t&quot; + columns[i]);
              }
              System.out.println();
              for (int row = 0; row &lt; table.length; row++) {
                  System.out.print(Rows[row]);
                  for (int col = 0; col &lt; table[row].length; col++) {
                      System.out.print(&quot;\t&quot; + table[row][col]);
                  }
                  System.out.println();
              }
              System.out.print(&quot;Enter row and column number to reserve separated by space (Enter a negative number to exit): &quot;);
              user_respo = sc.nextLine().split(&quot; &quot;);
              int row1 = Integer.parseInt(user_respo[0]);
              int col2 = Integer.parseInt(user_respo[1]);
              if (Integer.parseInt(user_respo[0]) &gt; 0 &amp;&amp; Integer.parseInt(user_respo[1]) &gt; 0) {
                  table[row1 - 1][col2 - 1] = &quot;   X  &quot;;
              } else if (Integer.parseInt(user_respo[0]) &lt; 0 &amp;&amp; Integer.parseInt(user_respo[1]) &lt; 0) {
                  System.out.println(&quot;Problem Exit!&quot;);
              } else {
                  System.out.println(&quot;Error&quot;);
              }
          } while (response == true);
      }
  
  }
  </code></pre>
  <p>When I input a negative number the error &quot;Exception in thread &quot;main&quot; java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
  at BusReservation.main(BusReservation.java:42)&quot;
  I have no idea how to make it say &quot;Progran Exit!&quot; instead.</p>