I am currently trying to get a high order function working, but it keeps telling me that f may not have been defined. My understanding is that it should be defined as it must be given in order to run the method IntApply. Any advice would be appreciated.
package iterators;
import java.util.Iterator;
public class IntApply implements Iterator {
// The function that will be applied to each input element to make an output element
private final IntApplyFunction f;
// The Iterator that this Apply object will get its input from
private final Iterator<Integer> input;
public IntApply(IntApplyFunction f, Iterator<Integer> input) {
while(input.hasNext()){
f.apply(input.next());
}
}
@Override
public boolean hasNext() {
return input.hasNext();
}
@Override
public Integer next() {
return input.next();
}
}