英语翻译Default constructor cannot handle exception type FileNotFoundException thrown by implicit super constructor.Must define an explicit constructorImplicit super constructor A() is not visible for default constructor.Must define an explicit c
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 09:59:23
英语翻译Default constructor cannot handle exception type FileNotFoundException thrown by implicit super constructor.Must define an explicit constructorImplicit super constructor A() is not visible for default constructor.Must define an explicit c
英语翻译
Default constructor cannot handle exception type FileNotFoundException thrown by implicit super constructor.Must define an explicit constructor
Implicit super constructor A() is not visible for default constructor.Must define an explicit constructor
英语翻译Default constructor cannot handle exception type FileNotFoundException thrown by implicit super constructor.Must define an explicit constructorImplicit super constructor A() is not visible for default constructor.Must define an explicit c
我用eclipse模拟出了你这两个错误:
package exception;
import java.io.*;
public class A {
public A()throws FileNotFoundException{
throw new FileNotFoundException();
}
}
public class B extends A{
public static void main(String[] args)
{
B b=new B();
}
}
以上会显示你的第一条错误提示信息,意恩就是:默认的子类构造函数无法解决由父类隐式构造函数抛出的FileNotFoundException(即无法找到文件异常),必须定义一个显示的构造函数(就像B没有定义构造函数,只能使用默认的构造函数).
package exception;
import java.io.*;
public class A {
private A(){
}
}
public class B extends A{
public static void main(String[] args)
{
B b=new B();
}
}
以上会出现你的第2条错误信息,看见没A的构造函数是private的.意思就是:隐式的父类构造函数A()对子类的默认构造函数是不可见的(not visible),必须定义一个显式的构造函数.
个别词:implicit 暗示的,隐示的 explicit 明确的,显示的.