Skip to content

Commit 7456de4

Browse files
committed
added Function sample code
1 parent 86a05b6 commit 7456de4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package java8.functionalInterface;
2+
3+
import java.util.function.Function;
4+
/**
5+
*
6+
* @author saurav
7+
*
8+
*/
9+
public class FunctionInterfaceDemo1
10+
{
11+
public static Integer show(String message){
12+
return Integer.parseInt(message);
13+
}
14+
public static void main(String[] args)
15+
{
16+
// Function interface referring to a method
17+
Function<String, Integer> fun = FunctionInterfaceDemo1::show;
18+
// Calling Function interface method
19+
System.out.println(fun.apply("4545")); // output : 4545
20+
}
21+
}

0 commit comments

Comments
 (0)