Function<Integer, Integer> doubleFunction = new Function<Integer, Integer>() {
@Override
public Integer apply(Integer integer) {
return integer * 2;
}
};
Function<Integer, Integer> squareFunction = new Function<Integer, Integer>() {
@Override
public Integer apply(Integer integer) {
return integer * integer;
}
};
Function<Integer, Integer> composeFunction = squareFunction.compose(doubleFunction);
int result = composeFunction.apply(5);
Join the Discord to ask follow-up questions and connect with the community
We are a Community full of Java developers. Connect with other devs, get help, help others and do much more!
27,739 Members
Join