title: NumberFormatException - try/catch for parse value
body: <p>I am very new to Java and to programming. I am doing an exercise to print to console a multiplication tab. I wanted to check user selection. I have been looking for different stackoverflow previous posts which have helpt me a lot to go further. However when I test the program its throw Exception :</p>
  <blockquote>
  <p>Exception in thread &quot;main&quot; java.lang.NumberFormatException: For input
  string: &quot;p&quot;   at
  java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  at java.lang.Integer.parseInt(Integer.java:580)     at
  java.lang.Integer.parseInt(Integer.java:615)  at
  TableMultiplication.main(TableMultiplication.java:18)</p>
  </blockquote>
  <p>Please, could you tell me what am I missing ? The error message is asking me to create breakpoint. I do not understand it.</p>
  <p>Thank you in advance</p>
  <pre><code>import java.util.Scanner;
  import java.util.InputMismatchException;
  
  public class TableMultiplication {
      public static void main(String[] args)
      {
          int table = -1;
          boolean wrongSelection = true;
          Scanner myObj = new Scanner(System.in);
  
          System.out.println(&quot;Multiplication tab will be shown to console &quot;);
  
          do{
              System.out.print(&quot;Enter the tab number you want, between 1 and 9 &quot;);
              while (wrongSelection) {
                  try {
                      String value = myObj.nextLine();
                      table = Integer.parseInt(value);
                      wrongSelection = false;
                  }
                  catch(InputMismatchException e){
                      System.out.println(&quot;Please, enter a number &quot;);
                      myObj.nextLine();
                  }
              }
          } while(table &lt; 1 || table &gt; 9);
  
          for(int i = 1; i &lt; 11; i++) {
              System.out.println(table + &quot; x &quot; + i + &quot; = &quot; + table * i);
          }
  
      }
  }
  </code></pre>