Result :
main 함수에서 예외를 발생시키는 함수 호출
>> throw Exception 함수 호출
>> catch 구문 : 예외를 처리한다
java.lang.Exception: private error 나만의 에러예요
>> 정상종료
Sample code :
package kame.ch13.ex01;
public class Ch13Ex07 {
public static void throwException(){
try{
System.out.println(" >> throw Exception 함수 호출 ");
throw new Exception (" private error 나만의 에러예요 ");
}catch(Exception e){
System.out.println(">> catch 구문 : 예외를 처리한다 ");
System.out.println(e);
}
}
public static void main(String[] args) {
System.out.println(" main 함수에서 예외를 발생시키는 함수 호출");
throwException();
System.out.println(">> 정상종료");
}
}
Reference book 이클립스로 배우는 Java 6 Programming/ 임종권, 전병찬/ 가메출판사
댓글 없음:
댓글 쓰기