title: how to check and display an error message if the input is not a number in java
body: <p>How to have a try and catch statement to validate the input in variable <strong>odd</strong> is a number else print an error message? I am new in java programming. Appreciate any help   </p>
  
  <pre><code>import java.util.Scanner;
  
  public class ScenarioB{
      public static void main (String[]args){
          int odd;
          Scanner scan = new Scanner(System.in);
          System.out.print("Enter An Odd Number\n");
          odd = scan.nextInt();
      }
  }
  </code></pre>