title: Validating user input in arrays
body: <p>Hey guys I am doing a project for school and am having a little trouble, I have a variable "reservationNumber" and im attempting to check if the number the user inputs is in the array, if not it returns a string saying the number was not found. It is working fine and displays the correct info when there is a valid input but when an invalid input is detected it gives a null.pointer.exception error. I tried writing it so that if the number is not detected the private method returns -1, then when I call the tickerInformation method, if that the variable 'ticket' returns -1 then it returns "invalid reservation number". This is where is error is being raised and only occurs when I enter an invalid number please help.</p>
  
  <pre><code>public void ticketInformation(String reservationNumber)
  {
        int ticket = searchArray(reservationNumber); 
  
        if (ticket == -1)
        {
           System.out.println("The reservation number entered was n0t found");
        }
        else
        {
          System.out.print("\n" + ticketSale[ticket].toString());
        }
  }
  
  private int searchArray(String reservationNumber)
  {
      for (int i = 0; i &lt; ticketSale.length; i++)
      {
          if (ticketSale[i].getReservationNumber().equals(reservationNumber))
          {
              return i;
          }
      }
      return -1;
  }
  </code></pre>