JAVA/예제
[JAVA] ch08-09. 예외 처리 9
밍글링글링
2017. 8. 22. 11:52
728x90
public class Ex09 {
public static void main(String[] args){
System.out.println(1);
System.out.println(2);
try{
System.out.println(3);
System.out.println(0/0);
System.out.println(4);
}catch(ArithmeticException ae) { //산술연산예외처리
System.out.println("ArithmeticException."); //catch를 여러번 사용할 때 자식 클래스의 exception 먼저 써준다.
처음부터 Exception 객체를 쓸 경우 다음 catch들을 실행 안하기 때문에.
}catch(Exception e){
System.out.println("Exception");
}
System.out.println(6);
}
}
728x90