Java 6일차 Exception 테스트2

/* 나만의 Exception 만들기 */

ThrowTest.java

public class ThrowTest
{
public static void main(String[] args)
{
int a = 100;

if(a == 100)
{
try
{
throw new ExceptionTest2();
}
catch(ExceptionTest2 e)
{
e.printStackTrace();
}
}
}
}

ExceptionTest2.java

public class ExceptionTest2 extends Exception
{
public ExceptionTest2()
{
super("my exception");
}
}

댓글 없음: