Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter08 : exception 본문

JAVA/chapter19_exception

chapter08 : exception

GAWON 2023. 5. 30. 09:31
package org.joonzis.ex;

// 예외 클래스 : Exception을 상속 받아서 만든다(Custom Exception)

// 예외 클래스를 만드는 이유 : 사용자 친화적인 예외 메세지로 변경 가능.
// 예외가 아닌 것도 예외로 만들 수 있다.
class MyException extends Exception{
	// 경고 없애려고 넣은거니까 신경쓰지말자 당장은
	private static final long serialVersionUID = 1L;

	public MyException(String message) {
		super(message);
	}
}
public class Ex08_exception {
	public static void main(String[] args) {
		
		try {
			throw new MyException("내가 만든 예외!");
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
	}
}

'JAVA > chapter19_exception' 카테고리의 다른 글

Test . exception  (0) 2023.05.30
chapter09 : exception  (0) 2023.05.30
chapter07 : exception  (0) 2023.05.30
chapter06 : exception  (0) 2023.05.30
chapter05 : exception  (0) 2023.05.30