0
다음 프로그램에서 main exception
을 얻으려고하면 프로그램의 첫 번째 예외를 일으키는 예외를 의미하므로 다음과 같은 오류가 발생합니다. cannot find symbol : e.getCause();
이 문을 제거한 후 System.out.println("Main Cause : " + e.getCause());
성공적으로 가져옵니다. 첫 번째 예외.연결 된 예외에서 심볼을 찾을 수 없음
class chain_demo {
static void demo() {
//create an exception
ArithmeticException e = new ArithmeticException("top Module");
//cuase an exception
e.initCause(new NullPointerException("Cause"));
//throw exception
throw e;
}
public static void main(String args[]) {
try {
demo();
}
catch(ArithmeticException e) {
//display top_level exception
System.out.println("Cautch : " + e);
}
//display cause exception
//getting error here
System.out.println("Main Cause : " + e.getCause());
}
}
그래서 어떻게 원인 예외를 얻을 수 있습니까?
아 ...... 그래서 실수가 ...... 알았어요 ..... –