예외 처리 클래스
1403 단어 예외 처리
class MyException1 extends Exception
{
int num;
MyException1(int a)
{
num = a;
}
public String toString()
{
return num+"<10! 10";
}
}
class MyException2 extends Exception
{
int num;
MyException2(int a)
{
num = a;
}
public String toString()
{
return num+">100!/r/n 100";
}
}
class MyExceptionTest
{
static void makeException(int a) throws MyException1,MyException2
{
if(a<10)
throw new MyException1(a);
if(a>100)
throw new MyException2(a);
System.out.println("No Exception");
}
public static void main(String[] args)
{
int a;
try
{
a = Integer.parseInt(args[0]);
makeException(a);
System.out.println("a="+a);
}
catch (MyException1 e)
{
System.out.println(""+e);
}
catch(MyException2 e)
{
System.out.println(""+e);
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Cycle Exception, PO가 json 시리얼화할 때 데드사이클 발생Exception in thread "main"net.ssk.json.JSONException: There is a cycle in the hierarchy! pojo에서 대상에 사순환 문제가 존재하는데 해결 방법:...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.