JAVA/예제

[JAVA] ch08-06. 예외 처리 6

밍글링글링 2017. 8. 22. 11:51
728x90
public class Ex06 {
    public static void main(String[] args){
        try{
            throw new Exception("willful");//throw: 예외처리 하겠다는 명령어. throw하는 순간 Exception객체 생성 가능,
  catch 블록으로 넘어감. Exception객체를 생성하면서 willful이라는 메시지를 담음.
        }catch(Exception e){
            System.out.println(e.getMessage());
            e.printStackTrace(); //객체 안에 있는 에러메시지를 전부 뽑아낼 수 있다. 발생한 시간 순서대로.
        }
        System.out.println("quit.");
    }
}
 

728x90