try-catch-finally
try-catch-finally. C'est OK sans la clause catch.instruction return à la fois dans la clause catch et dans la clause finally ↓
public class Test {
    public static void main(String... args) {
        System.out.println(getException());
    }
    private static String getException() {
        try {
            throw new Exception();
        } catch (Exception e) {
            return "catch!";
        } finally {
            return "finally!";
        }
    }
}
Le résultat de l'exécution est
finally!
Throwable
        -> Error
        -> Exception
            -> RuntimeException
Error
StackOverFlowtry-catch et throws ne sont pas appliqués, peuvent être écritsetRuntimeException`Exception
RuntimeException et ses sous-classestry-catch soit jetteRuntimeException
try-catch et throws ne sont pas appliqués, peuvent être écritsRecommended Posts