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
  • 1 comment:

    1. Free easy & simple way to learn java online and much more.. go to =>> http://foundjava.blogspot.in

      ReplyDelete

    Google+ Followers

    Google+ Badge