Tuesday, 27 June 2017

What is Constructor reference | Method reference in Java 8 | Java method reference

Click here to watch in Youtube :

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

Click the below link to download the code:

Github Link:

Bitbucket Link:

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

    Google+ Followers

    Google+ Badge