The Artima Developer Community
Sponsored Link

Java Buzz Forum
Non-Static Method reference - Dog | Method reference in Java 8 | Java method reference

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ram N

Posts: 2777
Nickname: ramram
Registered: Jul, 2014

Ram N is Java Programmer
Non-Static Method reference - Dog | Method reference in Java 8 | Java method reference Posted: Jun 14, 2017 6:46 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ram N.
Original Post: Non-Static Method reference - Dog | Method reference in Java 8 | Java method reference
Feed Title: JAVA EE
Feed URL: http://ramj2ee.blogspot.com/feeds/posts/default?alt=rss
Feed Description: This blog has viedo tutorials and Sample codes related to below Technologies. 1.J2EE 2.Java 3.Spring 4.Hibernate 5.Database 6.Oracle 7.Mysql 8.Design Patterns
Latest Java Buzz Posts
Latest Java Buzz Posts by Ram N
Latest Posts From JAVA EE

Advertisement

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
  • Read: Non-Static Method reference - Dog | Method reference in Java 8 | Java method reference

    Topic: Keeping Your Skills Up to Date as a Software Developer Previous Topic   Next Topic Topic: Electronic Signature Using The WebCrypto API

    Sponsored Links



    Google
      Web Artima.com   

    Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use