Tuesday 27 June 2017

What are the different method reference types | Method reference in Java 8 | Java method reference


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

Click the below Image to Enlarge
What are the different method reference types | Method reference in Java 8 | Java method reference 
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
  • What is Constructor reference | Method reference in Java 8 | Java method reference


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

    Click the below Image to Enlarge
    What is Constructor reference | Method reference in Java 8 | Java method reference 
    LambdaDemo.java
    @FunctionalInterface
    interface Message
    {
        String displayMessage(char[] chArray);
    }
    
    public class LambdaDemo
    {
        public static void main(String[] args)
        {
    
            /*
             * Note that, in this program strFunc() of FunctionalInterface
             * returns a reference of type String. In this program, the
             * expression "String::new" creates a constructor reference to
             * the String's constructor.
             */
            Message message = String::new;
    
            char[] charArray =  { 'P', 'e', 't', 'e', 'r' };
    
            /*
             * Here the method StrFunc() takes a Character array as an
             * argument, so the parameterized constructor 
             * String(char[] charArray) is referred here.
             * 
             * So finally, when ever you call the method strFunc() on
             * FunctionalInterface reference, a String object is
             * constructed and returned.
             */
            System.out.println(message.displayMessage(charArray));
        }
    
    }
    
    Output
    Peter
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_Cons_ref_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_Cons_ref_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
  • Instance method reference of an existing object| Method reference in Java 8 | Java method reference


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

    Click the below Image to Enlarge
    Instance method reference of an existing object| Method reference in Java 8 | Java method reference 
    Mechanic.java
    import java.util.function.Consumer;
    
    class Car
    {
        private String name;
    
        public Car(String name)
        {
            super();
            this.name = name;
        }
    
        public String getName()
        {
            return name;
        }
    
        public void setName(String name)
        {
            this.name = name;
        }
    
    }
    
    public class Mechanic
    {
        public void fix(Car c)
        {
            System.out.println("Mechanic is fixing " + c.getName());
        }
    
        public void execute(Car car, Consumer<Car> c)
        {
            c.accept(car);
        }
    }
    
    LambdaDemo.java
    import java.util.function.Consumer;
    
    public class LambdaDemo
    {
        public static void main(String[] args)
        {
    
            final Mechanic mechanic = new Mechanic();
            Car car = new Car("Honda Jazz");
    
            // Using an anonymous class
            mechanic.execute(car, new Consumer<Car>()
            {
                public void accept(Car c)
                {
                    mechanic.fix(c);
                }
            });
    
            // Using a lambda expression
            mechanic.execute(car, c -> mechanic.fix(c));
    
            // Using a method reference
            mechanic.execute(car, mechanic::fix);
        }
    
    }
    
    Output
    Mechanic is fixing Honda Jazz
    Mechanic is fixing Honda Jazz
    Mechanic is fixing Honda Jazz
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_Instance_method_ref_mechanic-app.zip?attredirects=0&d=1

    Github Link:
    https://github.com/ramram43210/Java/tree/master/BasicJava/LambdaDemo_Instance_method_ref_mechanic-app

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_Instance_method_ref_mechanic-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
  • Thursday 15 June 2017

    Static Method reference - Number more than 50| Method reference in Java 8 | Java method reference


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

    Click the below Image to Enlarge
    Static Method reference - Number more than 50| Method reference in Java 8 | Java method reference 
    Numbers.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.function.BiPredicate;
    
    class Numbers
    {
        public static boolean isMoreThanFifty(int n1, int n2)
        {
            return (n1 + n2) > 50;
        }
    
        public static List<Integer> findNumbers(List<Integer> list,
                                            BiPredicate<Integer, Integer> p)
        {
            List<Integer> newList = new ArrayList<>();
            for (Integer i : list)
            {
                if (p.test(i, i + 10))
                {
                    newList.add(i);
                }
            }
            return newList;
        }
    }
    
    LambdaDemo.java
    import java.util.Arrays;
    import java.util.List;
    import java.util.function.BiPredicate;
    
    public class LambdaDemo
    {
        public static void main(String[] args)
        {
    
            List<Integer> list = Arrays.asList(12, 5, 45, 18, 33, 24, 40);
    
            // Using an anonymous class
            List<Integer> listOfNumbers = Numbers.findNumbers(list, new BiPredicate<Integer, Integer>()
            {
                public boolean test(Integer i1, Integer i2)
                {
                    return Numbers.isMoreThanFifty(i1, i2);
                }
            });
            
            System.out.println("listOfNumbers using a anonymous class = "+listOfNumbers);
            
            // Using a lambda expression
            listOfNumbers =Numbers.findNumbers(list, (i1, i2) -> Numbers.isMoreThanFifty(i1, i2));
            System.out.println("listOfNumbers using a lambda expression = "+listOfNumbers);
            
            // Using a method reference
            listOfNumbers = Numbers.findNumbers(list, Numbers::isMoreThanFifty);
            System.out.println("listOfNumbers using a method reference = "+listOfNumbers);
        }
    
    }
    
    Output
    listOfNumbers using a anonymous class = [45, 33, 24, 40]
    listOfNumbers using a lambda expression = [45, 33, 24, 40]
    listOfNumbers using a method reference = [45, 33, 24, 40]
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_static_method_ref_more50_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_static_method_ref_more50_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
  • Static Method reference - Number less than 50| Method reference in Java 8 | Java method reference


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

    Click the below Image to Enlarge
    Static Method reference - Number less than 50| Method reference in Java 8 | Java method reference 
    Numbers.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.function.Predicate;
    
    class Numbers
    {
        public static boolean isLessThanFifty(int number)
        {
            return number < 50;
        }
    
        public static List<Integer> findNumbers(List<Integer> list,
                                                    Predicate<Integer> p)
        {
            List<Integer> newList = new ArrayList<>();
            for (Integer i : list)
            {
                /*
                 * test the number is less than 50
                 * then add to the newList.
                 */
                if (p.test(i))
                {
                    newList.add(i);
                }
            }
            return newList;
        }
    }
    
    LambdaDemo.java
    import java.util.Arrays;
    import java.util.List;
    import java.util.function.Predicate;
    
    public class LambdaDemo
    {
        public static void main(String[] args)
        {
    
            List<Integer> list = Arrays.asList(12, 55, 75, 88, 24, 40);
    
            // Using an anonymous class
            List<Integer> listOfLessthanfiftyNumbers = Numbers.findNumbers(list, new Predicate<Integer>()
            {
                public boolean test(Integer i)
                {
                    return Numbers.isLessThanFifty(i);
                }
            });
            
            System.out.println("listOfLessthanfiftyNumbers - anonymous class = "+listOfLessthanfiftyNumbers);
            
            // Using a lambda expression
            listOfLessthanfiftyNumbers = Numbers.findNumbers(list, (i) -> Numbers.isLessThanFifty(i));
            System.out.println("listOfLessthanfiftyNumbers - lambda expression = "+listOfLessthanfiftyNumbers);
            
            // Using a method reference
            listOfLessthanfiftyNumbers = Numbers.findNumbers(list, Numbers::isLessThanFifty);
            System.out.println("listOfLessthanfiftyNumbers - method reference = "+listOfLessthanfiftyNumbers);
        }
    
    }
    
    Output
    listOfLessthanfiftyNumbers - anonymous class = [12, 24, 40]
    listOfLessthanfiftyNumbers - lambda expression = [12, 24, 40]
    listOfLessthanfiftyNumbers - method reference = [12, 24, 40]
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_static_method_ref_less50_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_static_method_ref_less50_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
  • How to use Method reference in forEach method of List | Method reference in Java 8


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

    Click the below Image to Enlarge
    How to use Method reference in forEach method of List | Method reference in Java 8 
    How to use Method reference in forEach method of List | Method reference in Java 8 
    How to use Method reference in forEach method of List | Method reference in Java 8 
    MethodReferenceDemo.java
    import java.util.ArrayList;
    import java.util.List;
    
    public class MethodReferenceDemo
    {
        public static void main(String[] args)
        {
    
            List<String> nameList = new ArrayList<>();
            nameList.add("Peter");
            nameList.add("John");
            nameList.add("Juli");
            nameList.add("Stephan");
    
            nameList.forEach(name -> System.out.println(name));
            
            System.out.println("------------------------");
            
            // method reference
            nameList.forEach(System.out::println);
        }
    
    }
    
    Output
    Peter
    John
    Juli
    Stephan
    ------------------------
    Peter
    John
    Juli
    Stephan
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_list_foreach_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/769cad933ec9a28ea0eb78bc3917feeab1685676/BasicJava/LambdaDemo_method_ref_list_foreach_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
  • How to refer a constructor using method reference | Method reference in Java 8


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

    Click the below Image to Enlarge
    How to refer a constructor using method reference | Method reference in Java 8 
    MethodReferenceDemo.java
    /**
     *
     * We are using functional interface Messageable and referring constructor with
     * the help of functional interface.
     *
     */
    @FunctionalInterface
    interface Messageable
    {
        Message getMessage(String msg);
    }
    
    class Message
    {
        public Message(String msg)
        {
            System.out.print(msg);
        }
    }
    
    public class MethodReferenceDemo
    {
        public static void main(String[] args)
        {
            Messageable messageable = Message::new;
            messageable.getMessage("Hello");
        }
    }
    
    Output
    Hello
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_constructor_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_constructor_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
  • Non-Static Method reference - BiFunction | Method reference in Java 8 | Java method reference


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

    MethodReferenceDemo.java
    import java.util.function.BiFunction;
    
    /**
     *
     * We are using predefined functional interface BiFunction and
     * referring a non-static method add(int a, int b) to it's functional
     * method apply(Integer t,Integer u).
     *
     */
    
    class Arithmetic
    {
        public int add(int a, int b)
        {
            return a + b;
        }
    }
    
    public class MethodReferenceDemo
    {
        public static void main(String[] args)
        {
            BiFunction<Integer, Integer, Integer> adder = new Arithmetic()::add;
            int result = adder.apply(200, 200);
            System.out.println(result);
        }
    }
    
    Output
    400
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_nonstatic_Bifunction_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_nonstatic_Bifunction_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
  • Wednesday 14 June 2017

    Non-Static Method reference - Runnable| Method reference in Java 8 | Java method reference


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

    MethodReferenceDemo.java
    /**
     *
     * We are using predefined functional interface Runnable and referring
     * a non-static method ThreadStatus() to it's functional method run().
     *
     */
    
    public class MethodReferenceDemo
    {
        public void ThreadStatus()
        {
            System.out.println("Thread is running...");
        }
    
        public static void main(String[] args)
        {
            MethodReferenceDemo methodReferenceDemo = new MethodReferenceDemo();
            Runnable runnable = methodReferenceDemo::ThreadStatus;
            Thread thread = new Thread(runnable);
            thread.start();
        }
    }
    
    Output
    Thread is running...
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_nonstatic_runnable_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_nonstatic_runnable_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
  • Non-Static Method reference - Dog | Method reference in Java 8 | Java method reference


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

    Click the below Image to Enlarge
    Non-Static Method reference - Dog | Method reference in Java 8 | Java method reference 
    Non-Static Method reference - Dog | Method reference in Java 8 | Java method reference 
    MethodReferenceDemo.java
    /**
     *
     * We have defined a functional interface Dog and referring a
     * non-static method dogEating() to it's functional method eat().
     *
     */
    
    @FunctionalInterface
    interface Dog
    {
        void eat();
    }
    
    public class MethodReferenceDemo
    {
        public void dogEating()
        {
            System.out.println("Dog is eating chicken.");
        }
    
        public static void main(String[] args)
        {
            // Creating object
            MethodReferenceDemo methodReferenceDemo = new MethodReferenceDemo();
            
            // Referring non-static method using reference
            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_nonstatic_dog_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_nonstatic_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
  • Monday 12 June 2017

    Static Method reference - BiFunction Overload methods | Method reference in Java 8


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

    Click the below Image to Enlarge
    Static Method reference - BiFunction Overload methods | Method reference in Java 8 
    MethodReferenceDemo.java
    import java.util.function.BiFunction;
    
    /**
     *
     * We can also override static methods by referring methods. In the
     * following example, we have defined and overloaded three add
     * methods.
     *
     */
    
    class Arithmetic
    {
        public static int add(int a, int b)
        {
            return a + b;
        }
    
        public static float add(int a, float b)
        {
            return a + b;
        }
    
        public static float add(float a, float b)
        {
            return a + b;
        }
    }
    
    public class MethodReferenceDemo
    {
        public static void main(String[] args)
        {
            BiFunction<Integer, Integer, Integer> adder1 = Arithmetic::add;
            BiFunction<Integer, Float, Float> adder2 = Arithmetic::add;
            BiFunction<Float, Float, Float> adder3 = Arithmetic::add;
    
            int result1 = adder1.apply(10, 20);
            System.out.println(result1);
            
            float result2 = adder2.apply(10, 20.3f);
            System.out.println(result2);
            
            float result3 = adder3.apply(10.6f, 20.8f);     
            System.out.println(result3);
        }
    }
    
    Output
    30
    30.3
    31.4
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_static_BiFunc_overload_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_static_BiFunc_overload_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
  • Static Method reference - BiFunction | Method reference in Java 8 | Java method reference


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

    MethodReferenceDemo.java
    import java.util.function.BiFunction;
    
    /**
     *
     * We are using predefined functional interface BiFunction and
     * referring a static method add(int a, int b) to it's functional
     * method apply(Integer t,Integer u).
     *
     */
    
    class Arithmetic
    {
        public static int add(int a, int b)
        {
            return a + b;
        }
    }
    
    public class MethodReferenceDemo
    {
        public static void main(String[] args)
        {
            BiFunction<Integer, Integer, Integer> adder = Arithmetic::add;
            int result = adder.apply(20, 20);
            System.out.println(result);
        }
    }
    
    Output
    40
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_static_BiFunc_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_static_BiFunc_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
  • Static Method reference - Runnable| Method reference in Java 8 | Java method reference


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

    MethodReferenceDemo.java
    /**
     *
     * We are using predefined functional interface Runnable and referring
     * a static method ThreadStatus() to it's functional method run().
     *
     */
    
    public class MethodReferenceDemo
    {
        public static void ThreadStatus()
        {
            System.out.println("Thread is running...");
        }
    
        public static void main(String[] args)
        {
            Runnable runnable = MethodReferenceDemo::ThreadStatus;
            Thread thread = new Thread(runnable);
            thread.start();
        }
    }
    
    Output
    Thread is running...
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_static_Runnable_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_static_Runnable_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
  • Static Method reference - Person| Method reference in Java 8 | Java method reference


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

    Click the below Image to Enlarge
    Static Method reference - Person| Method reference in Java 8 | Java method reference 
    Static Method reference - Person| Method reference in Java 8 | Java method reference 
    MethodReferenceDemo.java
    /**
     * 
     * We have defined a functional interface person and referring a
     * static method personWalking() to it's functional method walk().
     *
     */
    
    @FunctionalInterface
    interface Person
    {
        void walk();
    }
    
    public class MethodReferenceDemo
    {
        public static void personWalking()
        {
            System.out.println("Walking on the road.");
        }
    
        public static void main(String[] args)
        {
            // Referring static method
            Person person = MethodReferenceDemo::personWalking;
            // Calling interface method
            person.walk();
        }
    }
    
    Output
    Walking on the road.
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/LambdaDemo_method_ref_static_person_app.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/525432e9afa25ee5052810cb2318f64453ffeffa/BasicJava/LambdaDemo_method_ref_static_person_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