Why the correct output of this java code is 22? Not 12? : <p>I was solving some java-tasks and had a problem with that one:</p>

<pre><code>What is the output of this code?

public class Test {
  public static int test(int i) {
    try {
      if (i == 0) throw new Exception();
      return i;
    } catch (Exception e) {
        return 1;
    } finally {
        return 2;
    }
}

  public static void main(String[] args) {
    System.out.print(test(0));
    System.out.print(test(3));
  }
}
</code></pre>

<p>The correct answer of that code is 22.</p>

<p>Could someone, please, explain to me, why 22? Why not 12?</p>

<p>Thanks!</p>
