Albert Albert - 28 days ago 6
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?

Answer

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.