title: How to throw an exception if user input is anything but string?
body: <p>My problem is that I need to throw an exception when the user inputs anything other than an alphabet. </p>
  
  <p>I can't change the fact that I'm using BufferedReader because it's part of an assignment for school. Here is my code: </p>
  
  <pre><code>public static String phoneList(String lastNameInput, String nameInput)
          throws IOException {
  
      BufferedReader bufferedreader = new BufferedReader(
              new InputStreamReader(System.in));
  
      try {
  
          System.out.println("Please input your first name.");
          // User input block
          String input = bufferedreader.readLine();
          nameInput = input;
      } catch (IOException e) {
          System.out.println("Sorry, please input just your first name.");
      }
  
      try {
          System.out.println("Please input your last name.");
          String input2 = bufferedreader.readLine();
          lastNameInput = input2;
      } catch (IOException e) {
          System.out
                  .println("Sorry, please only use letters for your last name.");
      }
      return (lastNameInput + ", " + nameInput);
  
  }
  </code></pre>
  
  <p>So what method can I use to throw an exception if the user input contains a number, or non-alphabet character?</p>