|
public class a15
{
public static void main(String[] args)
{
int arr[]={4,12,87,21,6,18};
int den[]={2,0,7,0,61,0};
double sum=0.0;
for(int i=0;i<=6;i++)
{
/*if((den==0)||(i>den.length-1))
{
System.out.println("程序执行有誤");
break;
}
else
{
sum+=(double)arr/den;
System.out.println("sum="+sum);
}*/
try
{
sum+=(double)arr/den;
System.out.println("sum="+sum);
}
catch(ArithmeticException e)
{
System.out.println("除数為0");
}
catch (ArrayIndexOutOfBoundsE1xception e)
{
System.out.println("超出数组大小");
}
}
System.out.println("Hello 2World!");
}
}
欢迎來到Java学习者論坛,转zai請注ming地址:http://www.javaxxz.com. |
|