One way to achieve this with Java Optional type:
public void f() {
final int a = Optional.<Integer>empty().orElseGet(() -> {
try {
return operationCanThrow();
} catch(final Exception e) {
return 42;
}
});
}