Click here to watch in Youtube :
https://www.youtube.com/watch?v=m0Lfxlm5h-g&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial: Lambda expression in java | Java Lambda expressions[Lambda expressions introduction] |
Java Tutorial: Lambda expression in java | Java Lambda expressions[Lambda expressions introduction] |
Java Tutorial: Lambda expression in java | Java Lambda expressions[Lambda expressions introduction] |
Java Tutorial: Lambda expression in java | Java Lambda expressions[Lambda expressions introduction] |
@FunctionalInterface //It is optional
public interface Dog
{
public void eat();
}
NoLambdaDemo.javapublic class NoLambdaDemo
{
public static void main(String[] args)
{
/*
* Without lambda, Dog implementation using anonymous class
*/
Dog dog = new Dog()
{
@Override
public void eat()
{
System.out.println("eating chicken");
}
};
dog.eat();
}
}
Outputeating chicken
LambdaDemo.javapublic class LambdaDemo
{
public static void main(String[] args)
{
/*
* With lambda
*/
Dog dog = () ->
{
System.out.println("eating chicken");
};
dog.eat();
}
}
Outputeating chicken
Click the below link to download the code:
No comments:
Post a Comment