title: How to check if user input is String, double or long in Java
body: <p>I'm a beginner in java. I want to check first if the user input is String or Double or int. If it's String, double or a minus number, the user should be prompted to enter a valid int number　again. Only when the user entered a valid number should then the program jump to try. I've been thinking for hours and  I come up with nothing useful.Please help, thank you!</p>
  
  <pre><code>import java.util.InputMismatchException;
  import java.util.Scanner;
  
  public class Fizz {
  
  public static void main(String[] args) {
  
      System.out.println("Please enter a number");
  
      Scanner scan = new Scanner(System.in);
  
      try {
  
          Integer i = scan.nextInt();
  
          if (i % 3 == 0 &amp;&amp; (i % 5 == 0)) {
              System.out.println("FizzBuzz");
          } else if (i % 3 == 0) {
              System.out.println("Fizz");
          } else if (i % 5 == 0) {
              System.out.println("Buzz");
          } else {
              System.out.println(i + "は3と5の倍数ではありません。");
          }
      } catch (InputMismatchException e) {
          System.out.println("");
  
      } finally {
          scan.close();
      }
  
  }
  </code></pre>