title: How to use an if statement to check if user input is a certain variable type?
body: <p>I'm creating a math program where a user inputs an answer. I want to display a message that says "All solutions must be entered as decimal numbers". How would I make sure that the user inputs a double and if not display that message. I've tried this so far:</p>
  
  <pre><code>if(userLetter.equalsIgnoreCase("a")) {
      System.out.print("What is the solution to the problem:" + " " + ran1Shift + " " + "+" + " " + ran2Shift + " = ");
      double userNum = input.nextDouble();
          if(userNum == additionAnswer){
              System.out.println("That's correct!");
          }
          else{
              System.out.println("The correct solution is: " + additionAnswer);
          }
      }
  </code></pre>
  
  <p>So basically I have it set now to display whether the answer is exactly true or false but how could I make another part which catches if the user enters a non-double? Thank you for your help :)</p>