I have a Abstract Iterator class which has this function
void iterate(){
    while(this.hasnext()){
        ..this.next()..
    }
}
How do I pass in any arbitrary function that will be applied to the next element. For example, is there a way to do iterate(print)?