求助

来源:互联网 发布:c 定义无长度数组 编辑:程序博客网 时间:2024/06/09 17:12
class MyException extends Exception{
    MyException(String ErrorMessage)
{
        
super(ErrorMessage);
    }

}

public class Excep11{
    
static int avg(int a,int b) throws MyException{
        
if(a<0||b<0)
        
throw new MyException("error1");
        
else if(a>100||b>100)
        
throw new MyException("too large");
        
return (a+b)/2;
    }

    
public static void main(String[] args){
        
try{
            Excep11 aaa
=new Excep11();
            
int y=aaa.avg(10,20);
        }
catch(MyException e){
            System.out.println(e);
        }

        System.out.println(y);
    }

}

 

提示在21行 System.out.println(y);找不到符号

求各位大大解答,谢谢了

原创粉丝点击