If you think you can, you can. If you think you can't, you are right.
SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA
Live life to an interface, not an implementation!
Originally posted by Kayalvizhi Umashankar:
finally block is meant for cleaning up after an exception occurs. Hence the return statement in it contradicts the purpose. Thats why the warning message is generated.
This is what i understand
Kayal
If you think you can, you can. If you think you can't, you are right.
java.lang.RuntimeException: Test
at test.A.foo(A.java:12)
at test.A.main(A.java:7)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Exception in thread "main"
SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
Thanks & Regards<br /> <br />-Srikanth
Originally posted by George Bolyuba:
As you can see this code throws an RuntimeException and the output should be like this:
(In case you using IDEA like I do )
But if you put return statement inside finally block you will not get RuntimeException and stack trace. It will looks like RuntimeException was never thrown.
[ August 10, 2005: Message edited by: George Bolyuba ]
If you think you can, you can. If you think you can't, you are right.
Shiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|