Friday 2 June 2017

Static Method reference - Dog | Method reference in Java 8 | Java method reference


Click here to watch in Youtube :
https://www.youtube.com/watch?v=W-hOaskWxMU&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Static Method reference - Dog | Method reference in Java 8 | Java method reference 
Static Method reference - Dog | Method reference in Java 8 | Java method reference 
MethodReferenceDemo.java
/**
 *
 * We have defined a functional interface Dog and referring a
 * static method dogEating() to it's functional method eat().
 *
 */

@FunctionalInterface
interface Dog
{
    void eat();
}

public class MethodReferenceDemo
{
    public static void dogEating()
    {
        System.out.println("Dog is eating chicken.");
    }

    public static void main(String[] args)
    {
        // Referring static method
        Dog dog = MethodReferenceDemo::dogEating;
        // Calling interface method
        dog.eat();
    }
}
Output
Dog is eating chicken.
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_static_dog_app.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/LambdaDemo_method_ref_static_dog_app

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/b58cad09932cc81678f7144749cb560485c5bdd8/BasicJava/LambdaDemo_method_ref_static_dog_app/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment