일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 토큰경제
- html video
- html object
- #성적관리프로그램
- mac terminal command
- relative path
- #JAVASCRIPT
- html5 new tag
- #C++ 연산자함수오버로딩
- git flow
- html multimedia
- html youtube
- border-box
- html id
- #3차원배열
- #CallByAddress
- #자바상속#자바이즈어#is~a
- html code
- 하이퍼레저패브릭
- #android activity
- #다차원포인터
- #binary
- #2차원배열
- html plug-in
- hyperledger transaction
- #bubbleSort
- docker example
- html charset
- #C++ has~a
- #1차원배열
Archives
- Today
- Total
A sentimental robot
예외처리, try~catch 본문
public class Day3 {
public static void main(String[] args) {
try {
int a = 3 / 0;
} catch (Exception e) {
System.out.println("error"); // try에서 에러가 나면 catch문으로 넘어온다.
e.printStackTrace(); // 지금 어떤 exception이 발생 했는 지 출력해준다.
}
class Apple {
void func01() {
try {
throw new Exception(); // throw->exception을 발생시킴 ,throw는 반드시 try/catch문이 받아야함!!
} catch (Exception e) {
}
}
void func02() throws Exception {
throw new Exception();
}
}
Apple apple = new Apple();
apple.func01();
// apple.func02(); // Unhandled exception -> func02를 호출할 때 tryCatch를 책임지라! Ctrl+1 > Surround with try/catch
try {
apple.func02();
} catch (Exception e) {
}
}
}
'Java' 카테고리의 다른 글
객체참조 (0) | 2018.01.09 |
---|---|
다운캐스팅, Downcasting (0) | 2018.01.09 |
자바에서 대표적인 예외 (0) | 2018.01.09 |
우주에서 랜덤하게 살아남기 (0) | 2018.01.08 |
CRUD, LinkedList (0) | 2018.01.08 |