September 5, 2010 at 5:49 PM
try/catch blocks are used for proveiding user under standable message on cosoule. where as throw use to make the related exception in our program.
where as throws used for just report exception to jvm it does not make the any exception.
when we are comeing to checked/unchecked exception here we findout main use for throw/throws.
when we raise the checked exception using throw here before raising thatr one must inform that exception using throws.see below program
static void m1()throws IlligalArgumentException
System.out.println("static void m1()");
public static void main(String args)
IAE is checked exception,here we can not stmt
"throws IlligalArgumentException" it leads to compiletime error:
main use of try/catch is program terminate normaly.