Notice
Recent Posts
Recent Comments
Link
«   2025/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
관리 메뉴

개발용

예외처리 Exception 본문

개발/JAVA

예외처리 Exception

DeP 2016. 11. 10. 19:48

ex)

class Exc_name extends Exception

{

Exc_name()

{

super("Error-Message");

}

}

 

 

"Exception던진 메소드를 호출하는 상위 메소드에서 예외처리 해줘야 함 : try-catch || throws"

 

*Solution

-try-catch : 필요한 곳에서 던지고 받음

try

{

...

if(EXCEPTION_OPTION)

{

throw new Exc_name();

}

}

catch(Exc_name e)

{

System.out.println(e.getMassage());    //Error-Message 출력

System.out.println(e.stackTrace());

}

 

 

-Method_name() throws Exc_name(throw Exc_name 한 메소드에서)

 

 

 

 

*clone() : Object Class의 인스턴스 메소드 :

 

-원형 : protected Object clone() throws CloneNotSupportedException

=> try-catch or throws CloneNotSupportedException

 

 

 

'개발 > JAVA' 카테고리의 다른 글

제네릭 & 컬렉션  (0) 2016.11.16
자바가상머신의 메모리 분류방식  (0) 2016.11.16
Interface, Abstract, 추상 클래스, 추상 메소드  (0) 2016.11.10
inner class  (0) 2016.11.10
Random  (0) 2016.11.10