Hi there,
I've tried to look into this issue but I'm having difficulty finding a solution.
I have two classes: PaymentDate and its subclass PaymentDateRef. PaymentDate has a method setMaturityPeri od that is called in the PaymentDate constructor, which ultimately sets the variable maturityPeriod.
In PaymentDateRef I have written a method setMaturityPeri od which I believed should override the superclass method of the same name.
Now, when I call the constructor of PaymentDateRef I must also reference the constructor of PaymentDate through the super keyword. However, what I am seeing is that this then calls setMaturityPeri od within PaymentDate and then from within the constructor of PaymentDateRef. ..i.e. the setMaturityPeri od method is called twice.
public PaymentDate() {
setMaturityPeri od();
}
public PaymentDateRef( ) {
super();
setMaturityPeri od();
}
Does anyone know how I can call setMaturityPeri od only once from within the constructor? I thought the override property would cause the new setMaturityPeri od to be called rather than the old, allowing the PaymentDateRef constructor to be used:
public PaymentDateRef( ) {
super();
}
but in this case only the original setMaturityPeri od method is called.
I've tried to look into this issue but I'm having difficulty finding a solution.
I have two classes: PaymentDate and its subclass PaymentDateRef. PaymentDate has a method setMaturityPeri od that is called in the PaymentDate constructor, which ultimately sets the variable maturityPeriod.
In PaymentDateRef I have written a method setMaturityPeri od which I believed should override the superclass method of the same name.
Now, when I call the constructor of PaymentDateRef I must also reference the constructor of PaymentDate through the super keyword. However, what I am seeing is that this then calls setMaturityPeri od within PaymentDate and then from within the constructor of PaymentDateRef. ..i.e. the setMaturityPeri od method is called twice.
public PaymentDate() {
setMaturityPeri od();
}
public PaymentDateRef( ) {
super();
setMaturityPeri od();
}
Does anyone know how I can call setMaturityPeri od only once from within the constructor? I thought the override property would cause the new setMaturityPeri od to be called rather than the old, allowing the PaymentDateRef constructor to be used:
public PaymentDateRef( ) {
super();
}
but in this case only the original setMaturityPeri od method is called.
Comment