请问,下面的程序在我的电脑出现如图所示的错误,是什么原因?
classMyExceptionextendsException{privateintexceptnumber;MyException(inta){exceptnumbe...
class MyException extends Exception
{
private int exceptnumber;
MyException(int a)
{
exceptnumber=a;
}
public String toString()
{
return "MyException["+exceptnumber+"]";
}
}
class ExceptionExample
{
static void makeexcept(int a) throws MyException
{
System.out.println("Called makeexcept("+a+")");
if(a==0)
throw new MyException(a);
System.out.println("exit without exception!");
}
public static void main(String args[])
{
try
{
makeexcept(4);
makeexcept(0);
}
catch(MyException e)
{
System.out.println("Caught"+e);
}
}
} 展开
{
private int exceptnumber;
MyException(int a)
{
exceptnumber=a;
}
public String toString()
{
return "MyException["+exceptnumber+"]";
}
}
class ExceptionExample
{
static void makeexcept(int a) throws MyException
{
System.out.println("Called makeexcept("+a+")");
if(a==0)
throw new MyException(a);
System.out.println("exit without exception!");
}
public static void main(String args[])
{
try
{
makeexcept(4);
makeexcept(0);
}
catch(MyException e)
{
System.out.println("Caught"+e);
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询