Functional interfaces - examples:
@FunctionalInterface
interface Walkable {
public String walk();
}
@FunctionalInterface
interface Sayable{
void say(String msg);
}
and after using:
Walkable walkWithLambda = () -> {
return "I want to walk around.";
};
walkWithLambda.walk();
Sayable sayWithLambda = (msg) - > {
System.out.println(msg);
};
sayWithLambda.say("I want to say something important!");
https://dzone.com/articles/introduction-functional-1
https://docs.oracle.com/javase/8/docs/api/?java/lang/FunctionalInterface.html
https://stackoverflow.com/questions/36881826/what-are-functional-interfaces-used-for-in-java-8
https://www.javaguides.net/2018/07/java-8-functional-interfaces.html
https://www.javaguides.net/2018/11/java-functionalinterface-annotation.html
https://github.com/RameshMF/java-8-tutorial/tree/master/src/com/ramesh/java8/functionalInterfaces
No comments:
Post a Comment