public class simple {
public static void main(String[] args) {
try {
System.out.print("hello ");
throwit();
} catch (Exception re) {
System.out.print("caught ");
}
}
public static void throwit(){ // line number 11
throw new Exception(); // line number 12
}
}
줄 번호 12에 컴파일 오류가 표시됩니다. 줄 번호 11에 대해 예외를 throw하는 경우 제대로 작동합니다. 예외의 하위 클래스를 던지면 (12 번 줄에서) 제대로 작동합니다 ... 이유는 무엇입니까? ...왜 try catch 문에서 호출 된 메서드에서 Exception (checked)을 throw 할 수 없습니까?
사실 나는 뒤쪽에서 어떤 일이 발생 하는지를 알고 싶습니다.
해야한다,에 관계없이하여 throwit 어떤 코드를 호출의 그 선언 할 필요가있다. – MatrixFrog