public void play() throws IOException {
try (JavableBook book = new JavableBook();
JavableVideo video = new JavableVideo();){ //----(1)
book.page(150);
video.scene(150); //----(2)
}
}
(3)의 단계가 보이지 않음
try-with-resource 에서는 구절이 모두 끝나게 된다면 자동으로 자원을 반납하기 때문
숨겨진 예외들도 그냥 버려지지는 않고, 스택 추적 내역에 ‘숨겨졌다 (suppressed)’는 꼬리표를 달고 출력됨
[Item 9] try-finally보다는 try-with-resources를 사용하라
(지양) try-finally
(권장) try-with-resources
참고 https://tecoble.techcourse.co.kr/post/2021-04-26-try-with-resource/