title: Throwing exception in main method
body: <p>I am trying to figure out why I have to <code>throw</code> exception in the main method while I have <code>try</code>/<code>catch</code> blocks that can handle those exceptions anyway? 
  Even if I delete <code>throws IllegalArgumentException,InputMismatchException</code> part, the program will still compile and work perfectly.</p>
  
  <pre><code>public static void main(String[] args) throws IllegalArgumentException,InputMismatchException{
      boolean flag = true;
      Scanner in = new Scanner(System.in);
      do{
          try{
              System.out.println("Please enter the number:");
              int n = in.nextInt();
              int sum = range(n);
              System.out.println("sum = " + sum);
              flag = false;
          }
          catch(IllegalArgumentException e){
              System.out.println(e.getMessage());
          }
          catch(InputMismatchException e){
              System.out.println("The number has to be as integer...");
              in.nextLine();
          } 
  </code></pre>