Click here to watch in Youtube :
https://www.youtube.com/watch?v=91sd5c23Eoo&list=UUhwKlOVR041tngjerWxVccw
LambdaDemo.java
https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_parenthesis_app.zip?attredirects=0&d=1
https://www.youtube.com/watch?v=91sd5c23Eoo&list=UUhwKlOVR041tngjerWxVccw
LambdaDemo.java
@FunctionalInterface
interface GreetingService
{
void sayMessage(String message);
}
public class LambdaDemo
{
public static void main(String[] args)
{
// with parenthesis
GreetingService greetService1 = message ->
System.out.println("Hello " + message);
// without parenthesis
GreetingService greetService2 = (message) ->
System.out.println("Hello " + message);
greetService1.sayMessage("Peter");
greetService2.sayMessage("John");
}
}
OutputHello Peter
Hello John
Click the below link to download the code:https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_parenthesis_app.zip?attredirects=0&d=1
No comments:
Post a Comment