专本贯通是什么意思:怎么抛出14个异常呢?应该是4个异常啊!!那里的问题哦

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 03:28:52
怎么抛出14个异常呢?应该是4个异常啊!!那里的问题哦
class NotIdolNumberException extends Exception
{
NotIdolNumberException()
{
super("不是偶数");
}
}
class IsDivisorPerseException extends Exception
{
IsDivisorPerseException()
{
super("是除数本身");
}
}
class CustomException
{
public static void main(String args[])
{
int num1[]={4,8,15,32,64,127,256,512};
int num2[]={2,1,2,4,4,4,8};
try
{
for(int i=0;i<num1.length;i++)
{
for(int j=0;j<=i;j++)
{
try
{
if((num1[i]/num2[j])%2!=0)
throw new NotIdolNumberException();
if(num1[i]/num2[j]==num1[i])
throw new IsDivisorPerseException();
}
catch(NotIdolNumberException e)
{
System.out.println(e);
}
catch(IsDivisorPerseException e)
{
System.out.println(e);
}
}
}
}
catch(ArrayIndexOutOfBoundsException e)
{}
}
}

if((num1[i]/num2[j])%2!=0)
throw new NotIdolNumberException();
if(num1[i]/num2[j]==num1[i])
throw new IsDivisorPerseException();