Java error: Implicit super constructor is undefined for default constructor
来源:互联网 发布:对流风和穿堂风知乎 编辑:程序博客网 时间:2024/04/28 04:54
今天帮忙给同学做一道Java作业题的时候,碰见了这个错误
Implicit super constructor Person() is undefined for default constructor. Must define an explicit constructor
You get this error because a class which has no constructor has a default constructor, which is argument-less and is equivalent to the following code:
public ACSubClass() { super();}
However since your BaseClass declares a constructor (and therefore doesn't have the default, no-arg constructor that the compiler would otherwise provide) this is illegal - a class that extends BaseClass can't call super();
because there is not a no-argument constructor in BaseClass.
This is probably a little counter-intuitive because you might think that a subclass automatically has any constructor that the base class has.
The simplest way around this is for the base class to not declare a constructor (and thus have the default, no-arg constructor) or have a declared no-arg constructor (either by itself or alongside any other constructors). But often this approach can't be applied - because you need whatever arguments are being passed into the constructor to construct a legit instance of the class.
- Java error: Implicit super constructor is undefined for default constructor
- 错误:Implicit super constructor xx() is undefined for default constructor.
- error:Implicit super constructor Object() is undefined for default constructor..的解决方法
- Implicit super constructor xx() is undefined for default constructor. Must define an explicit constr
- Implicit super constructor xx() is undefined for default constructor. Must define an explicit constr
- Implicit super constructor Object() is undefined for default constructor. Must define an explicit c
- Implicit super constructor xx() is undefined for default constructor. Must define an explicit constr
- 错误:Implicit super constructor Fu() is undefined for default constructor. Must define an explicit con
- Implicit super constructor Object() is undefined for default constructor. Must define an explicit co
- Implicit super constructor Object is undefined for default constructor. Must define an explicit cons
- Implicit super constructor Object() is undefined for default constructor. Must define an explicit co
- implicit super constructor Dialog() is undefined
- 子类编写构造器报错 Implicit super constructor Cigerate() is undefined
- Implicit super constructor BaseService() is undefined. Must explicitly invoke another constructor
- 关于Implicit super constructor FF() is undefined. Must explicitly invoke another constructor
- 错误:Implicit super constructor Father() is undefined. Must explicitly invoke another constructor
- 编译器需要implicit nontrivial default constructor情况
- The constructor Date() is undefined
- 如何在socket编程的Tcp连接中实现心跳协议
- 一个关于char在不同平台下 的bug
- 推荐一本新手学习使用GitHub的必读书
- 页面间值的获取
- iOS开发 UI篇 — 懒加载
- Java error: Implicit super constructor is undefined for default constructor
- 一道淘汰85%面试者的百度开发者面试题
- hackerrank Find Digits && Upotain tree
- STL forward_list
- 通过写代码和虚拟机命令截取网上数据
- 黑马程序员——Java集合框架—Queue—Deque—ArrayDeque
- 最近似乎都没怎么自学,觉得很愧疚,慎独真的很重要
- uvalive3971(二分+贪心)
- HHKB开箱记录