对super的调用必须是构造函数中的第一个语句?

来源:百度知道 编辑:UC知道 时间:2024/09/26 16:29:37
改错!
到底该怎么改?
就是在自定义异常中super所在的那一行有错误:(对super的调用必须是构造函数中的第一个语句?)
怎么改,速求答案!
希望大家踊跃发言,谢谢了!
class MyException extends Exception{

public void Excepion(String s) {
super(s);
}

public void printMsg(){
System.out.println("MyException:"+this.getMessage());
this.printStackTrace();
System.exit(0);
}
}

public class Try2{
public static void main(String args[]){
byte y=1,i=1;
for (i=1;1<=10;i++){
System.out.print(i+"!=");
try{
if(y>Byte.MAX_VALUE/i) //Tnteger类的常量
throw new Exception("overflow!"); //溢出时抛出异常
else{
y= (byte) (y * i);
System.out.println(y);
}
}catch(MyException e){
e.printMsg();
}
}
}
}

你应该 说的详细些 这样没人懂!!!!!!!!!!帮不了你!唉.....

super()必须在构造方法中使用。并且super()必须放在第一句。

但是 public void Excepion(String s) 并不是构造函数。
构造函数没有返回值。
public Excepion(String s) 才是构造函数。