java中子类如何继承有参数的父类方法

classfathertest{publicfathertest(inti){System.out.println("hello"+"i");}}publicclasst... class fathertest{
public fathertest(int i){
System.out.println("hello"+"i");
}

}

public class test extends fathertest {
super test(int i){
//错误:Implicit super constructor fathertest() is undefined. Must explicitly invoke another
// constructor
System.out.println("java");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
test s=new test(0);
}

}
不是说只要在子类方法构造中用super加参数就可以了吗?请问该如何修改?
展开
 我来答
匿名用户
2016-09-25
展开全部
class fathertest{
public fathertest(int i){
System.out.println("hello"+"i");
}
}

public class test extends fathertest {
test(int i){
super(i);
System.out.println("java");
}
public static void main(String[] args) {
test s=new test(0);
}

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式