try-catch-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!";
}
}
}
Das Ausführungsergebnis ist
finally!
Throwable
-> Error
-> Exception
-> RuntimeException
Error
try-catch
und throw
werden nicht erzwungen, können geschrieben werdenException
und RuntimeException
Exception
RuntimeException
und seine UnterklassenRuntimeException
try-catch
und throw
werden nicht erzwungen, können geschrieben werdenRecommended Posts