title: What comes first - finally or catch block?
body: <p>Consider the following test case:</p>
  
  <pre><code>public class Main {
  
      static int a = 0;
  
      public static void main(String[] args) {
          try {
              test();
              System.out.println("---");
              test2();
          }
          catch(Exception e) {
              System.out.println(a + ": outer catch");
              a++;
          }
      }
  
      public static void test()
      {
          try {
              throw new Exception();
          }
          catch (Exception e) {
              System.out.println(a + ": inner catch");
              a++;
          }
          finally {
              System.out.println(a + ": finally");
              a++;
          }
      }
  
      public static void test2() throws Exception
      {
          try {
              throw new Exception();
          }
          finally {
              System.out.println(a + ": finally");
              a++;
          }
      }
  }
  </code></pre>
  
  <p>With output:</p>
  
  <pre><code>0: inner catch
  1: finally
  ---
  2: finally
  3: outer catch
  </code></pre>
  
  <p>What's the explanation for why in <code>test()</code> catch happens before finally while in <code>test2()</code> it's the other way around?</p>