에게 약간의 배경을 제공합니다자바 : 클래스 확장, 서브 클래스의 생성자는 오류
관련된 세 가지 클래스가 있습니다 Tester(main method)
, DNASequence(object)
및 ProteinDNA(subclass of DNASequence)
가. 세 명 모두 같은 패키지하에 있습니다.
는 ProteinDNA
의 생성자는 생성자에서 나에게 오류를 제공 객체 DNASequence
및 클래스 ProteinDNA
컴파일 정수
public class ProteinDNA extends DNASequence{
public ProteinDNA(DNASequence dna, int startAt){ //this is the constructor
을 받아들입니다.
이클립스의 오류는 다음과 같습니다
"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"
? 테스터 클래스는 적절하게 구성된 인스턴스 DNASequence
을 ProteinDNA
에 제공합니다.
'ProteinDNA' _is a_'DNASequence', 그래서 그것은 DNASequence 생성자를 명시 적으로 호출 할 필요가 있습니다. –
http://stackoverflow.com/questions/9143317/java-inheritance-error-implicit-super-constructor-is-undefined – Kojotak
DNASequence에서 인수가없는 생성자를 생성하면 문제가 해결됩니다! 고맙습니다! – user1766889