: 여기 자바의 다형성 (polymorphism)/추상 클래스 도움
public abstract class NewMath {
public abstract int op (int intOne, int intTwo);
}
가 확장 된 서브 클래스 :
public class MultMath extends NewMath {
public int op (int intOne, int intTwo){
return intOne + intTwo;
}
}
하지만 객체 동안 인스턴스화 할 때 다음과 같은 매개 변수를 정의하십시오.
public class TestNewMath {
public static void main(String [] _args) {
MultMath multObj = new MultMath(3,5);
}
}
작동하지 않습니다. 그것은 내게이 오류를 준다 :
TestNewMath.java:3: cannot find symbol symbol : constructor AddMath(int,int) location: class AddMath AddMath addObj = new AddMath(3, 5);
나는 뭔가를 놓친다는 것을 알고있다. 이게 뭐야?
어디에서 생성자를 넣을 까? – Phil
생성자는 반환 유형 및 클래스 이름이없는 메소드입니다. 이 경우 공용 MultMath (int intOne, int intTwo) – Confusion