title: Entering string instead of integer (Java)
body: <p>I am an absolute beginner, no experience in any programming language.</p>
  
  <p>I wrote a program as an exercise for converting Arabic numbers to Roman numbers. It works. However I want to add a part for dealing with problem if a string  is entered instead of integer. And don't know how to do this. I tried to use try/catch, but I don't know how to use it correctly. Now the program asks me twice to enter a number. What to do?</p>
  
  <p>Here is he main method: </p>
  
  <pre><code>public static void main(String[] args) {
  
      int numArabic; 
      boolean validEntry;
  
      try {
              System.out.println("Enter an integer number between 1 and 3999!");
              Scanner scan = new Scanner(System.in); 
              numArabic = scan.nextInt();
              validEntry = true;
          } catch (InputMismatchException e) {
              System.out.println("Entered value is not an integer!");
          }
  
      System.out.println("Enter an integer number between 1 and 3999!");
      Scanner scan = new Scanner(System.in); 
      numArabic = scan.nextInt();                            
  
      if ((numArabic &lt; 1) || (numArabic &gt; 3999)) {
              System.out.println();
              System.out.print("Wrong number. ");
              System.out.print("Enter an integer number between 1 and 3999!");
              System.out.println();
              }
      else {
              String numRoman1 = toRomanOne(numArabic % 10);
              String numRoman2 = toRomanTwo(((numArabic / 10) % 10));
              String numRoman3 = toRomanThree(((numArabic / 100) % 10));
              String numRoman4 = toRomanFour(numArabic / 1000);
              System.out.print("The number " + numArabic + " is equal to: ");
              System.out.print(numRoman4+numRoman3+numRoman2+numRoman1 + ".");
      }
  }
  </code></pre>