有三类涉及:,DNASequence(object)
和ProteinDNA(subclass of DNASequence)
。所有三个都在同一个包中。
为ProteinDNA
构造函数接受一个对象DNASequence
和整数
public class ProteinDNA extends DNASequence{
public ProteinDNA(DNASequence dna, int startAt){ //this is the constructor
编译类ProteinDNA
给我一个错误的构造函数。
Eclipse中的错误是:
"Implicit super constructor `DNASequence()` is undefined.
Must explicitly invoke another constructor"
在jGrasp的错误是:
ProteinDNA.java:16: error:
constructor DNASequence in class DNASequence cannot be applied to given types;
public ProteinDNA(DNASequence dna, int startAt)^{
required: String
found: no arguments
reason: actual and formal argument lists differ in length"
我在做什么错?测试程序类将ProteinDNA
与适当构建的DNASequence
实例一起提供。
'ProteinDNA''就是'DNASequence',所以你需要明确调用'DNASequence'构造函数,因为它看起来没有无参数构造函数。 –
您将在http://stackoverflow.com/questions/9143317/java-inheritance-error-implicit-super-constructor-is-undefined中找到答案 – Kojotak
在DNASequence中创建无参数构造函数可修复此问题!谢谢! – user1766889