코딩테스트/해커랭크 챌린지
[hackerrank] hackerrank challenges Day 16 자바 강의 리뷰
dandev
2022. 7. 9. 11:15
반응형
해커랭크 Day 16 챌린지를 시작해보자. 🔥
오늘은 Exception에 대해서 배웠다.
먼저 소스코드부터 확인해보자.
public class ExceptionsPractice {
public static void main(String[] args) {
// int[] intArray = new int[10];
// System.out.println(intArray[10]);
try {
int[] c = new int[5];
System.out.println("Element 6 at index 5 = " + c[5]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Exception thrown" + e);
} finally {
System.out.println("Finally clause");
}
// System.out.println("Finally Finished try-catch");
/**
* 1. checked Exceptions
* - occurs at compile time(syntax)
* 2. unchecked Exceptions
* - occurs at the time your program is executed(logic)
*/
/**
* try-catch block
* try {
* do this until we get an exception
* } catch(type_of_error e) {
* do this if we get type_of_error
* in the try
* }
*/
}
}
설명을 많이 적어두느라
소스코드보다 주석이 더 많지만
주석에도 많은 정보를 담고있으므로
제외시키지 않고 첨부하였다.
exception의 기본인
try-catch를 이용한 예외처리와
finally 메서드를 공부하였다.
수업 소스 코드는 아주 간단하므로
설명은 생략하겠다!!
이해되지 않는 부분이 있다면
댓글을 통해 질문하길 바란다!!
그럼 우리는 Day 16 문제 풀이 포스팅으로 다시 만나자 😊
반응형