/**
* {@link <a href=
* "https://[Log in to view URL]"
* target= "_blank"></a>}
*
* @author itammb ( Italia Massimiliano Buscati )
* @version JDK 1.15
*
*/
// The main method must be in a class named "Main".
class Main {
@FunctionalInterface
public interface FirstInterface { // interfaccia funzionale ( assegnazione a una funzione anonima)
public void singleMethod(String param);
}
public static class FirstInterfacePrinter {
public void print(FirstInterface firstInterface) { // funzione anonima assegnata come parametro
firstInterface.singleMethod("apple");
}
}
private static class UniTest {
public void labda(FirstInterfacePrinter printer) {
printer.print((String param) -> { // parametro passato
System.out.println("My lambda says " + param); // labda expesion - corpo
});
}
}
public static void main(String args[]) {
// Unit test - composizione di una funzione anonima
new UniTest().labda(new FirstInterfacePrinter());
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: