Albert Albert - 4 months ago 34
Java Question

Java: general function X->Y interface

I need an interface like:

interface Function<X,Y> {
Y eval(X obj);

Is there something like this in Java already or do I need to define my own?


Unfortunately, there's no such thing in the core Java libraries. As a consequence, many libraries define their own function-like interface. If you happen to use such a library already, you can re-use the function it uses.