We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e929c8b commit 3614719Copy full SHA for 3614719
Java相关/What's New in JDK8/Lambda表达式.md
@@ -60,3 +60,29 @@ public interface Runnable {
60
- ```Predicate<T> {boolean test(T t);}``` 判断,接受一个T对象,返回一个布尔值。
61
- ```Supplier<T> {T get();} 提供者(工厂)``` 返回一个T对象。
62
- 其他的跟上面的相似,大家可以看一下function包下的具体接口。
63
+## 4.变量作用域
64
+```java
65
+public class VaraibleHide {
66
+ @FunctionalInterface
67
+ interface IInner {
68
+ void printInt(int x);
69
+ }
70
+ public static void main(String[] args) {
71
+ int x = 20;
72
+ IInner inner = new IInner() {
73
+ int x = 10;
74
+ @Override
75
+ public void printInt(int x) {
76
+ System.out.println(x);
77
78
+ };
79
+ inner.printInt(30);
80
+ inner = (s) -> {
81
+ //!int x = 10;
82
+ //!x= 50; error
83
+ System.out.print(x);
84
85
86
87
+}
88
+```
0 commit comments