Java 6일차 Exception 테스트

public class ExceptionTest
{
public static void main(String[] args)
{
try
{
int result = 1/0;
}
catch(ArithmeticException e)
{
System.out.println("Print 1");
}

try
{
int result[] = new int[5];
result[10] = 1;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Print 2");
}

try
{
int result = Integer.parseInt("error");
}
catch(NumberFormatException e)
{
System.out.println("Print 3");
}
finally
{
System.out.println("Print 4");
}
}
}

댓글 없음: