반응형
Checked Exception과 Unchecked Exception
-
7강. 코틀린에서 예외를 다루는 방법BackEnd/Kotlin 2024. 2. 7. 22:00
try catch finally 구문 Checked Exception과 Unchecked Exception try with resources try catch finally 구문 try catch finally 문법 자체는 Java와 Kotlin 모두 동일합니다. 단, Kotlin의 try catch는 if-else 혹은 if-else if-else 처럼 하나의 Expression 으로 간주됩니다. 다음은 Java로 작성된 예외를 처리하는 예제 코드입니다. private int parseIntOrThrow(@NotNull String str) { try { return Integer.parseInt(str); } catch (NumberFormatException e) { throw new Illegal..