Java - 자바 입문 무료 (프로그래머스) 예외처리 throws

parkkhee·2023년 2월 25일
0

옹숭깊다

목록 보기
7/18
public class ExceptionExam{
    public int get50thItem(int []array) throws ArrayIndexOutOfBoundsException{
        return  array[49];
    }
}

ExceptionExam클래스의 get50thItem메소드에서는 매개변수로 받은 array의 50번째 값을 return합니다. 만약 array의 크기가 50보다 작을 경우에는 ArrayIndexOutOfBoundsException이라는 예외가 발생하는데요. get50thItem이 ArrayIndexOutOfBoundsException를 throw하도록 정의해 보세요.

profile
순우리말 백엔드 개발자

0개의 댓글