-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.java
39 lines (33 loc) · 1.24 KB
/
Example.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.trl.theoreticalKnowledge.lambda.body.a.a1;
import static java.lang.System.out;
public class Example {
public static void main(String[] args) {
// There is one more issue you might see with lambdas. We’ve been defining an argument list in our lambda
// expressions. Since Java doesn’t allow us to re‐declare a local variable, the following is an issue:
// out.println(
// testLambda_1(
// "Hello",
// str -> {
// String str = ""; // Compilation ERROR !!!
// return str.concat(" World !!!");
// }
// )
// );
out.println(
testLambda_1(
"Hello",
str -> {
String str_2 = "";
return str.concat(" World !!!");
}
)
);
}
public static String testLambda_1(String str, SomeFunctionlInterface_1 in) {
return in.someMethod(str);
}
}
@FunctionalInterface
interface SomeFunctionlInterface_1 {
String someMethod(String str);
}