title: Why to declare ioexception when numberformatexception occurring?
body: <pre><code>try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      str = br.readLine();
      i = Integer.parseInt(str);
  } catch(NumberFormatException e) {
      System.out.Println("enter a valid input");
  }
  </code></pre>
  
  <p>When I try to compile this code it throws a compile error that ioexception is occuring I should catch it.</p>
  
  <p>Therefore I have to add a <code>catch(IOException e)</code> statement, but the exception  that occurs is a number format exception of <code>java.lang</code> library so why do I have to catch <code>ioException</code>.</p>