Java/2012.04 강좌
12일차 Exception(예외처리 미루기)
Bohemian life
2012. 4. 19. 11:26
package hi.choongang; public class P262Exam { //a메서드를 실행하다가 예외가 발생하면 //a를 호출한 곳으로 예외처리를 미룬다(보낸다) static void a() throws Exception { System.out.println("a 메서드 시작"); throw new Exception("내가만든 익셉션"); } public static void main(String[] args) { System.out.println("시작"); try { a();//메서드 호출//>>>>>>여기로 보내집니다<<<<<< System.out.println("--------");//실행안되고 바로 catch로 감 } catch (Exception e) { System.out.println("던진것 받았다."); } System.out.println("끝"); } }