public class Div
{
int[] a={4,4,11,7,9},b={2,0,7};
public void Function()
{
for(int i=0;i
try
{
if(a[i]>10) throw new MyException();
System.out.println(a[i]+" / "+b[i]+" = "+a[i]/b[i]);
}
catch(ArithmeticException e)
{
System.out.println("除数为0");
}
catch(IndexOutOfBoundsException e)
{
System.out.println("数组下标越界!");
}
catch(MyException e)
{
System.out.println("被除数大于10");
}
}
}
public static void main(String[] args)
{
new Div().Function();
}
}
class MyException extends Exception
{}