Take a look at this:
public static interface IFunction<T> {
public void callFunction(T t);
}
private static IFunction<String> functionPointer = new IFunction<String>() {
@Override
public void callFunction(String t) {
System.out.println(t);
}
};
public static final List<IFunction<?>> functions = new ArrayList<>();
{
functions.add(functionPointer);
}
public void inOrderTraversalFrom(BinaryTreeNode node, List<IFunction<?>> actions) {
if(node.left != null)
inOrderTraversalFrom(node.left, null);
IFunction<String> func = (IFunction<String>) actions.get(0);
func.callFunction("Hello function pointer");
if(node.right != null)
inOrderTraversalFrom(node.right, null);
}
That's a quick and dirty solution but that's a kind of
function pointing in java.
You can use generic parameter to change the parameters but you must declare parameter classes for each function signature.