728x90
반응형
package chap9;
/*
* throw 예제
*/
public class ExceptionEx6 {
public static void main(String[] args) {
try {
//throw : JVM으로 예외 통지함.
throw new Exception("예외 강제 발생");
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
System.out.println("프로그램 종료");
}
}
728x90
반응형
'study > Java' 카테고리의 다른 글
[Java] 26. Exception8 (예외 클래스 생성) (0) | 2022.03.22 |
---|---|
[Java] 26. Exception7 (오버라이딩에서 예외 처리) (0) | 2022.03.22 |
[Java] 26. Exception5 (throw) (0) | 2022.03.22 |
[Java] 26. Exception4 (throws) (0) | 2022.03.22 |
[Java] 26. Exception3 (finally) (0) | 2022.03.22 |