44
55import java .util .List ;
66import java .util .function .BiFunction ;
7- import java .util .function .Function ;
8- import java .util .function .IntBinaryOperator ;
97import java .util .function .Predicate ;
108
119public class Syntax {
@@ -27,7 +25,7 @@ public static void main(String[] args) {
2725
2826
2927 // no input, 1 return
30- useZeroParameters (() -> 2 );
28+ System . out . println ( useZeroParameters (() -> 2 ) );
3129// SAME AS USING THIS:
3230// useZeroParameters(new ZeroArguments() {
3331// @Override
@@ -38,7 +36,7 @@ public static void main(String[] args) {
3836
3937
4038 // 1 input, 1 return
41- usePredicate (text -> text .isEmpty ());
39+ System . out . println ( usePredicate (text -> text .isEmpty (), "" ));
4240// SAME AS USING THIS:
4341// usePredicate(new Predicate<String>() {
4442// @Override
@@ -49,8 +47,8 @@ public static void main(String[] args) {
4947
5048
5149 // 2 inputs, 1 return
52- useBiFunction ((Integer x , Integer y ) -> x * y );
53- useBiFunction ((x , y ) -> x * y );
50+ System . out . println ( useBiFunction ((Integer x , Integer y ) -> x * y , 2 , 3 ) );
51+ System . out . println ( useBiFunction ((x , y ) -> x * y , 4 , 5 ) );
5452// SAME AS USING THIS:
5553// useBiFunction(new BiFunction<>() {
5654// @Override
@@ -66,14 +64,16 @@ public static void main(String[] args) {
6664
6765
6866 // 2 inputs, 1 return
69- useBiFunction ((x , y ) -> {
67+ System . out . println ( useBiFunction ((x , y ) -> {
7068 System .out .println ("X: " + x + ", Y:" + y );
7169 return x - y ;
72- });
70+ }, 6 , 7 ) );
7371
7472
7573 // no input, no return
76- useNothing (() -> System .out .println ("Hola Alumno" ));
74+ useNothing (() -> {
75+ });
76+ useNothing (() -> System .out .println ("Me ejecute sin recibir ni devolver elementos" ));
7777// SAME AS USING THIS:
7878// useNothing(new DoNothing() {
7979// @Override
@@ -84,19 +84,23 @@ public static void main(String[] args) {
8484
8585 }
8686
87- static void useZeroParameters (ZeroArguments zeroArguments ) {
87+ static int useZeroParameters (ZeroArguments lamda ) {
88+ return lamda .get ();
8889 // static class to implement FunctionalInterface
8990 }
9091
91- static void usePredicate (Predicate <String > predicado ) {
92+ static boolean usePredicate (Predicate <String > lamda , String text ) {
93+ return lamda .test (text );
9294 // static class to implement FunctionalInterface
9395 }
9496
95- static void useBiFunction (BiFunction <Integer , Integer , Integer > operacion ) {
97+ static Integer useBiFunction (BiFunction <Integer , Integer , Integer > lamda , Integer x , Integer y ) {
98+ return lamda .apply (x , y );
9699 // static class to implement FunctionalInterface
97100 }
98101
99- static void useNothing (DoNothing doNothing ) {
102+ static void useNothing (DoNothing lambda ) {
103+ lambda .nothing ();
100104 // static class to implement FunctionalInterface
101105 }
102106
0 commit comments