| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- GitHub_Actions
- Docker
- 백엔드 로드맵
- Spring API
- Interface
- 인스턴스
- button
- spring
- Java
- 어떤 개발자?
- oAuth2
- 카카오인증토큰받기
- 카카오인가코드받기
- input
- tag
- 예외
- 백엔드공부
- MIND 2023 #후기
- 엔티티 매니저
- 백엔드스쿨
- 엔티티 생명주기
- 카카오사용자정보가져오기
- ci/cd
- 제로베이스
- feignClient
- jenkins
- 상속
- static
- html
- form
Archives
- Today
- Total
HiDevelop
쉽게 배우는 JAVA 2-6(예외 변수 e) 본문
728x90
"이 글은 글쓴이가 부스트 코스의 쉽게 배우는 JAVA2를 통해 배운 점을 적는 공간입니다."
변수 e
e는 하나의 인스턴스로 다양한 기능을 사용할 수 있다.
public class ExceptionClass {
public static void main(String[] args) {
System.out.println(1);
int[] scores = {10,20,30};
try {
System.out.println(2);
// System.out.println(scores[3]);
System.out.println(3); //실행되지 않는 코드 try 아래전부
System.out.println(2/0);
System.out.println(4);
} catch(ArithmeticException e) {
System.out.println("ArithmeticException" + e.getMessage());
e.printStackTrace();
} catch(Exception e) {
System.out.println("Exception");
}
System.out.println(5);
}
}
위에서 e.getMessge(), e.printStackTrace()를 통해서 예외상황에 대한 정보를 얻을 수 있다.

더 많은 e에 대한 기능을 알아볼려면 아래 링크를 참고하기를 바란다.
https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#constructor.summary
Throwable (Java Platform SE 8 )
Provides programmatic access to the stack trace information printed by printStackTrace(). Returns an array of stack trace elements, each representing one stack frame. The zeroth element of the array (assuming the array's length is non-zero) represents the
docs.oracle.com
728x90
'Java' 카테고리의 다른 글
| Jave(Swtich문) (0) | 2021.10.23 |
|---|---|
| 쉽게 배우는 JAVA 2-7(예외 2) (0) | 2021.08.19 |
| 쉽게 배우는 JAVA 2-5(예외1) (0) | 2021.08.19 |
| 쉽게 배우는 JAVA2-4 (0) | 2021.08.15 |
| 쉽게 배우는JAVA2-3 (0) | 2021.08.10 |