본문 바로가기

콩's EDUCATION/콩's JAVA_RUN

예외(Exception) 처리 기본

예외처리 기본 예제


 

public class ExceptionTest {
 public static void main(String[] args) {
  try{
  int i = Integer.parseInt(args[0]);
  int j = Integer.parseInt(args[1]);
  System.out.println(i/j);
  }
  catch (ArithmeticException e) {
   e.printStackTrace();
   System.out.println("0을 입력하지 마시오");
  }
  System.out.println("완료");
 }
}

 

 

 

ExceptionTest.java