공부 기록/영상 후기
Java 예외 - 4. 예외의 우선순위
yurison
2023. 4. 26. 16:39
public class App {
public static void main(String[] args) {
try {
System.out.println(2/0);
} catch (ArithmeticException e) {
System.out.println("ArithmeticException");
} catch (Exception e) {
System.out.println("Exception");
}
}
}
위와 같은 경우 "ArithmeticException" 출력
public class App {
public static void main(String[] args) {
try {
System.out.println(2/0);
} catch (Exception e) {
System.out.println("Exception");
} catch (ArithmeticException e) {
System.out.println("ArithmeticException");
}
}
}
위와 같은 경우 ArithmeticException 부분이 필요 없어짐. "Exception" 출력