Skip to content

Commit d96a852

Browse files
committed
added Method References sample code
1 parent 477bfa7 commit d96a852

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package java8.lambda;
2+
interface Calc
3+
{
4+
void add(int a,int b);
5+
}
6+
public class LambdaDemo5
7+
{
8+
public LambdaDemo5(int x,int y)
9+
{
10+
System.out.println(x+y);
11+
}
12+
public static void main(String[] args)
13+
{
14+
// Reference to Constructor.
15+
Calc calc=LambdaDemo5::new;
16+
calc.add(10,10); // output : 20
17+
}
18+
}

0 commit comments

Comments
 (0)