In python, if I have a few functions that I would like to call based on an input, i can do this:
lookup = {\'function1\':function1, \'function2\':function2, \'fu
Unfortunately, Java does not have first-class functions, but consider the following interface:
public interface F {
public B f(A a);
}
This models the type for functions from type A
to type B
, as first-class values that you can pass around. What you want is a Map
.
Functional Java is a fairly complete library centered around first-class functions.