-Java에서는 try~catch~finally 구문을 통해 프로그래머가 예외 상황에 대응할 수 있도록 하고 있따.
	try{
		// 기본적으로 실행되는 부분
	} catch( 예외클래스이름 객체이름 ) {
		// try 블록에서 예외가 발생한경우
		// 이 곳으로 제어가 넘어온다
	} finally {
		//예외 상황의 발생 여부에 상관 없이
		// 무조건 샐행되는 부분
		// finally 블록은 생략 가능하다.
	}package exception;
public class Main05 {
	public static void main(String[] args) {
		
		try {
			String year2 = "10";
			int age2 = 2023 - Integer.parseInt(year2);
			System.out.println(age2);
			
			int[] arr = new int[3];
			for(int i = 0; i<5; i++) {
				arr[i] = i;
				System.out.println(arr[i]);
			}
		} catch(ArrayIndexOutOfBoundsException e) {
			System.out.println("에러발생");
			System.out.println("원인 : " + e.getMessage());
		} catch(NumberFormatException e) {
			System.out.println("에러발생");
			System.out.println("원인 : " + e.getMessage());
		} catch(Exception e) {
			System.out.println("알 수 없는 에러 발생");
			System.out.println(e.getMessage());
		}
		
		System.out.println("--프로그램을 종료합니다.--");
		
	}
}
복합적 예외상황에 대응하기
package exception;
//복합적 예외 상황에 대응하기
public class Main06 {
	public static void main(String[] args) {
		/*
		 * Exception 처리
		 * 예외의 발생여부와 상관없이 "데이터 변환 종료"
		 * 라는 문구 출력
		 */
		
			// 사용자가 입력한 값
		String[] src = { "5", "2", "4", "1324" };
			
			//src의 내용들을 숫자로 변환해서 저장할 배열
		int[] arr = new int[3];
			
		try {
			for(int i =0 ; i<src.length; i++) {
				arr[i] = Integer.parseInt(src[i]);
			}
		} catch ( NumberFormatException e ) {
			System.out.println("입력값에 오류가 있습니다.");
			//개발자가 보려는 용도로 출력하는 시스템 에러메세지
			e.printStackTrace();
		} catch ( ArrayIndexOutOfBoundsException e ) {
			System.out.println("데이터가 너무 많습니다.");
			e.printStackTrace();
		} catch( Exception e ) {
			/*
			 * 예외 종류를 의미하는 모든 클래스는 Exception 클래스를 상속받으므로,
			 * 이 블록은 모든 종류의 예외에 대처할 수 있다.
			 */
			System.out.println("알 수 없는 예외가 발생했습니다.");
			e.printStackTrace();
		}finally {	
			// 이 블록은 예외의 발생 여부에 상관없이 무조건 실행된다.
			System.out.println("데이터 변환 종료");			
		}
		System.out.println("프로그램을 종료합니다.");
		
	}
}