决赛与有效决赛的区别我正在使用Java 8中的lambdas,我遇到了警告local variables referenced from a lambda expression must be final or effectively final..我知道当我在匿名类中使用变量时,它们在外部类中必须是最终变量,但是-最终和有效终?
3 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
其值在初始化后从未更改的变量或参数实际上是最终变量或参数。
public class Foo {
public void baz(int bar) {
// While the next line is commented, bar is effectively final
// and while it is uncommented, the assignment means it is not
// effectively final.
// bar = 2;
}}添加回答
举报
0/150
提交
取消
