Java doesn't support function pointers. One workaround would be to name your functions methodically, i.e. f1, f2, f3, etc... and then create a Method object based off of that pattern. For example, using the function names f1, f2, f3, you could do this:
java.lang.reflect.Method method;
try {
methodName = "f" + String.valueOf((int) Math.random()*NUM_FUNCTIONS);
method = obj.getClass().getMethod(methodName, param1.class, param2.class, ..);
} catch (SecurityException e) {
// ...
} catch (NoSuchMethodException e) {
// ...
}
Then call the function like so:
try {
method.invoke(obj, arg1, arg2,...);
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
*This answer is heavily borrowed from here.