오류노트
[코딩 오류 노트] try 밖에서 throw 사용
망고고래
2023. 10. 24. 17:40
1. try 밖에서 throw 사용
오류 메시지
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type Exception
코드
public static void main(String[] args) {
Exception e = new Exception("고의 예외");
throw e;
}
throw e;
해결
throw는 try 안에서 사용해야 한다.