public class HelloWorld{ static int a; public static void main(String []args){ System.out.println("Hello World"); HelloWorld h =new HelloWorld(); a = h.foo(); System.out.println(a); } int foo() { try{ throw new Exception(); } catch(Exception e){ System.out.println("catch"); return 9; } finally{System.out.println(a);return 10;} } } When I ran the above code output was: Hello World catch 0 10 Now i have a doubt that does the return in catch is executed first or the finally block executed first??

Member Avatar
Member Avatar
+0 forum 1

How can I terminate resources in a safe way when JFrame is about to close? - If I put terminate() in the a finally block it runs before windowClosing(). - If I put terminate in windowClosing() it can't be accessed from an inner class. I am aware that I shouldn't use finalize(), but I don't know from where (and how) should I call my terminate() method. Is there an "official" way to **close a JFrame with windowClosing() and do some tasks** (save data, close streams) **before** the program **exits**? **Where should I put my terminate() method?** public class Test extends …

Member Avatar
Member Avatar
+0 forum 2

I am pretty new to programming in VB.Net, but I have been programming in other languages for a couple of decades now, including VB5/6 and C++. When I am using a **Try** - **Catch** block to handle exceptions, what is the point of a **Finally** section? Wouldn't it be just the same as putting code after the **End Try**? So why use a **Finally** section because it looks like it just gets executed after everything else in the block, which is the same behaviour as code after the **Try** - **Catch** block.

Member Avatar
Member Avatar
+0 forum 4

The End.