Is there a way of passing a function to another function and then executing it?
functionCaller(functionToBeCalled());
In java 8 you can use a method reference or lambda
functionCaller(this::functionToBeCalled);
or
functionCaller(() -> functionToBeCalled());
I don't know if I understand very well your question, but effectively you can call a function in param of another function.
You can do this (I suppose your current language is Java):
// if write(...) and getValue() are static method of Writer class
Writer.write(getValue());
// if write(...) and getValue() can just be used by instanciate an object
Writer writer = new Writer();
String val = writer.getValue();
writer.write(val);
There are basic Java programming lesson. Thanks