title: Getting java.util.InputMismatch upon typing "exit"
body: <pre><code>Scanner input = new Scanner (System.in);
  
      System.out.println("Enter -1 to exit the program");
      System.out.println("Enter the search key: ");
  
      int searchkey = input.nextInt();
      String exit = input.nextLine();
  
      while (!exit.equals("exit"))
      {
  
          linear(array, searchkey);
          binary(array,searchkey);
  
          System.out.println();
          System.out.println("Enter exit to end the program");
          System.out.println("Enter the search key: ");
  
          searchkey = input.nextInt();
          exit = input.nextLine();
  
      }
  </code></pre>
  
  <p>I am getting an InputMismatch exception. I know this is because of <code>searchkey</code>. How can I use the string to exit the program?</p>