import java.util.concurrent.ThreadLocalRandom; public class A { void f() { String s = ""; try { s = "a"; if (r()) throw new RuntimeException(); s = "b"; } finally { System.out.println(s); } } private boolean r() { return ThreadLocalRandom.current().nextBoolean(); } }