java - Exception thrown in method -


public class x {         public void foo() throws exception{               system.out.print("hi ");               throw new exception();  }   public static void main(string[] args) throws exception  {                  x c = new x();                   c.foo();     }  } 

as in foo() method throwing exception , propogating exception using throws. in main() method again propagating exception. when compile works fine.

my question : why dnt need handle throw new exception()? taking care of this?

it thrown err console your
main method declares "throws exception".
remove , won't compile anymore.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -