Here's a small Java snippet. Before reading on, decide what it returns: static int a() { int x = 1; try { return x; } finally { x = 99; } } If you said 99, you're in good company. I used to think the same thing: "finally runs before return, so x becomes 99 first, then gets returned." The actual answer is 1. finally does run before the method... Weiterlesen
Intelligence View
Does finally Run Before return? What javac Actually Does
Here's a small Java snippet. Before reading on, decide what it returns: static int a() { int x = 1; try { return x; } finally { x = 99; } } If you said 99, you're in good company. I used to think the same thing: "finally…
SOCIAL SHARE CARD GENERATOR