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
Post a Comment