麻烦看看为何THROW方法不能正常运行~~
smigo 2007-11-02 08:40:54 代码如下~
class ExceptionOne extends Exception{
ExceptionOne(){
System.out.println("结果不是偶数……");
}
}
class ExceptionTwo extends Exception{
ExceptionTwo(){
System.out.println("结果是本身……");
}
}
class CustomException{
protected CustomException(){
}
public static void main(String[] args){
int [] arr1={4,8,15,32,64,127,256,512};
int [] arr2={2,1,2,4,4,4,8};
int result;
try{
for(int i=0;i<arr1.length;i++){
result=arr1[i]/arr2[i];
if((result%2)!=0){
throw new ExceptionOne();
}else if(arr1[i]==result){
throw new ExceptionTwo();
}
}
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("数组越界……"+e);
}
}
}
图我不会贴……