Advertisement
sci4me

Java 8 Static Method References

May 23rd, 2015
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. public class Test
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         testAdder(Test::add);
  6.     }
  7.  
  8.     public static void testAdder(Adder adder)
  9.     {
  10.         System.out.println(adder.add(1, 2));
  11.     }
  12.  
  13.     public static int add(int a, int b)
  14.     {
  15.         return a + b;
  16.     }
  17.  
  18.     @FunctionalInterface
  19.     interface Adder
  20.     {
  21.         int add(int a, int b);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement