package com.java1.day19;
//ArithmeticException은 산술 연산과정에서 오류가 있을때 발생하는 예외이다.
public class ExceptionEx3 {
public static void main(String[] args) {
int number = 100;
int result = 0;
for (int i = 0; i < 10; i++) {
try {
result = number/(int)(Math.random() * 10);
System.out.println(result);
} catch (ArithmeticException e) {
System.out.println("0"); //ArithmeticException 이 발생하면 실행되는 코드..
}
}
}
}
16
14
12
14
50
14
25
12
0
50