티스토리 뷰

learning

Java, RuntimeException 에 대한 정리

눈침침 2012. 8. 15. 09:58

java.lang.Throwable

Java 언어의 Error 와 Exception 은 모두 java.lang.Throwable을 상속하고 있습니다. 이중 Error 는 try catch 구문으로 처리할 수 없는 비정상적인, 심각한 상태를, Exception은 조금 덜 심각한 상태를 의미합니다.

java.lang.RuntimeException

Exception은 꽤 많은 자식 클래스 들이 있습니다. 그중에 좀 특이한 녀석이 RuntimeException 입니다. RuntimeException은 JVM 의 보통 연산 중 발생할 수 있는 Exception 을 의미합니다. 대표적인 예가 ‘divide by zero’ 이며, 이 경우, RuntimeException 의 자식인 ArithmeticException 이 발생합니다.

RuntimeException 이 특이한 점은, try catch 혹은 throws 구문으로 Exception 처리를 명시하지 않아도 컴파일시 에러가 발생하지 않는 점입니다.

A method is not required to declare in its throws clause any subclasses of RuntimeException that might be thrown during the execution of the method but not caught.

RuntimeException Java Doc
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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
글 보관함