반응형
finally는 항상 출력
public class ExceptionTest {
public static void main(String[] args) {
try{
int i = Integer.parseInt(args[0]);
int j = Integer.parseInt(args[1]);
System.out.println(i/j);
}catch (Exception e) {
System.out.println("항상동일하게 처리합니다");
return; // 메소드 중단, 없으면 "완료" 표시된다.
//system.exit(0) // 클래스 수행종료. finally 내부 선언되지 않는다.
}finally{
System.out.println("항상 출력됩니다.");
}
System.out.println("");
System.out.println("완료");
}
}
결과
항상동일하게 처리합니다
항상 출력됩니다.
반응형
'콩's EDUCATION > 콩's JAVA_RUN' 카테고리의 다른 글
사용자 정의 예외 만들기 (0) | 2014.05.16 |
---|---|
throws 처리 (0) | 2014.05.16 |
예외(Exception) 처리 기본 (0) | 2014.05.16 |
Java 문제 4 (0) | 2014.05.15 |
인터페이스(interface) (0) | 2014.05.15 |