Monday, 12 June 2017

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


    1. I want to say is that.
      We face various problems while watching the game, so we have different problems to watch live games. I’m looking for a site.
      It’s really great that all types of games are shown live like NFL NHL SOCCER NBA etc. I am linking to a site, you can visit.
      hopefully you will come to your needs… http://nflsqtv.com http://nflsqtv.com
      —————————Just visit this site or Search NFLSQTV

      ReplyDelete