Suppose you received the following code:
public abstract class DecisionFunctionJ {
public abstract double evaluate();
public DecisionFunctionJ add(final DecisionFunctionJ another) {
return new DecisionFunctionJ() {
@Override
public double evaluate() {
return this.evaluate() + another.evaluate();
}
};
}
}
This code does not work as intended because it leads to an infinite circle / StackOverflowException. The reason for this is obvious: it this.evaluate()refers to the method of the evaluateinternal anonymous class, and not to the method of the evaluateexternal abstract class.
How can I execute an external method evaluate? Using DecisionFunctionJ.this.evaluate()does not help, because both classes are of type DecitionFunctionJ.
What are the other features?
source
share